Writes are atomic just like calling them from any other language. The warning is just pointing out that due to the asynchronous nature of javascript you must not assume any IO has happened until you get the callback. So if you don't wait for callbacks the order of the writes is not guaranteed. In your case of writing to a file from different places in your app, you wouldn't expect the order of writes to be guaranteed anyway.
On Sat, Mar 24, 2012 at 10:08 AM, Jaka Jančar <[email protected]> wrote: > I'm writing a node.js server that uses the cluster module. Each worker > does *lots* of logging to a shared log file (it must be just 1 file). > > - Assuming log lines are smaller than PIPE_BUF (4k), is it safe to do > fs.write() and rely on it being atomic, or does Node.js break this > promise of write()? > > - What's with "Note that it is unsafe to use fs.write multiple times > on the same file without waiting for the callback."? > > - If writes are not atomic or not waiting for callbacks really is a > problem, what's an *efficient* alternative? > > Thanks, > Jaka > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
