<div dir="ltr">Thanks your reply.<div><br></div><div>When I deep into NJS source you ponit to, I found something about GCC write file flag with O_APPEND</div><div><br></div><div>I google Linux GCC write file O_APPEND to learn something.</div><div><br></div><div>In fact NJS fs.writeFileSync() with O_APPEND, it is atomic write file if it's buffer just write all in one time. Even mutil process to write one file use O_APPEND.</div><div><br></div><div>But, if write buffer can NOT write all in one time, in mutil process, it is NOT atomic.</div><div><br></div><div>I found Nginx Log write is use O_APPEND to write atomic, even Nginx has a lot of workers.</div><div><br></div><div>And</div><div><br></div><div>I read the source code by your link `write-file-atomic`, it is hard to port to NJS. The reason is that NJS fs without fs.rename, and Nodejs write file atomic use temp file rename and write queue to make it.</div><div><br></div><div>Thanks.</div></div><br><div class="gmail_quote"><div dir="ltr">HENG <<a href="mailto:ourwaiting@gmail.com">ourwaiting@gmail.com</a>> 于2018年10月20日周六 上午12:55写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks your reply.<div><br></div><div>When I deep into NJS source you ponit to, I found something about GCC write file flag with O_APPEND</div><div><br></div><div>I google Linux GCC write file O_APPEND to learn something.</div><div><br></div><div>In fact NJS fs.writeFileSync() with O_APPEND, it is atomic write file if it's buffer just write all in one time. Even mutil process to write one file use O_APPEND.</div><div><br></div><div>But, if write buffer can NOT write all in one time, in mutil process, it is NOT atomic.</div><div><br></div><div>I found Nginx Log write is use O_APPEND to write atomic, even Nginx has a lot of workers.</div><div><br></div><div>And</div><div><br></div><div>I read the source code by your link `write-file-atomic`, it is hard to port to NJS. The reason is that NJS fs without fs.rename, and Nodejs write file atomic use temp file rename and write queue to make it.</div><div><br></div><div>Thanks.</div></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-553242442915280631m_880869650402828667gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>--------------------------------------------------------------------<br>Heng<br>---------------------------------------------------------------------<br>--<br></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>--------------------------------------------------------------------<br>Heng<br>---------------------------------------------------------------------<br>--<br></div></div></div>