lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Mar 16, 2009 at 1:55 AM, William Bubel <inmatarian@gmail.com> wrote:
> I've been seeing a lot of talk on the intertubes lately about how most
> application developers have been doing files the wrong way when it comes
> to the atomicity of their file transactions[1]. I was curious if there
> is a Lua way to do this yet. All I've seen in the ref manual is
> file:flush, which as of 5.1.3's source looks like a wrapper for fflush,
> and I believe that would only get the file out of the internal buffers
> and into the operating system's delayed allocation buffers.
>

"
Note that fflush() only flushes the user space buffers provided by  the
       C  library.   To  ensure that the data is physically stored on disk the
       kernel buffers must be  flushed  too,  for  example,  with  sync(2)  or
       fsync(2).
"

Apparently so, I wasn't aware of this, so thanks for pointing it out.
Have some code to fix :)

> For what its worth, the Python people seem to believe that fflush is the
> end of our responsibility as application developers[2].
>

The ext4 people claim that application developers have been doing the
Wrong Thing for some time. Fair enough, I'm happy to fix it.
Unfortunately it seems that fsync() on ext3 isn't great[1] :(

Problem 2 is that fsync() doesn't appear to be defined by ANSI C.

So it looks like we need an fsync() binding and a configuration option
in applications as to whether we should use it. In other words, not a
Lua interpreter issue per se.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=421482