emacs-devel
[Top][All Lists]
Advanced

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

Re: RMAIL file locking problem?


From: Evil Boris
Subject: Re: RMAIL file locking problem?
Date: Mon, 09 May 2005 23:03:45 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (windows-nt)

Richard Stallman <address@hidden> writes:

>     Or could one check the C code for "insert-file-contents"?  Does it
>     mark the buffer modified if 0 bytes were read.
>
> The code appears specifically to avoid marking the buffer modified
> if the file has zero size.  I just did a test, inserting an empty
> file into a buffer this way.  It did not mark the buffer modified
> and did not lock the file.
>
> Something we don't understand must be happening, and only you
> are in a position to debug it.

I have spent some time tracing the code of insert-file-contents.  I do
not understand what it is trying to do, to be honest, but this is what
it **appears** to be doing:  If the file it is trying to read has ZERO
bytes according to what stat() returns, it does the following:

----lines 176-181 of fileio.c
          /* The file size returned from stat may be zero, but data
             may be readable nonetheless, for example when this is a
             file in the /proc filesystem.  */
          if (st.st_size == 0)
            XSETINT (end, READ_BUF_SIZE);
---------

This has the effect of setting the amount to be read to non-zero.
Around line 707 it does

      total = XINT (end) - XINT (beg);

setting total to something very much other than zero (some buffer
size), and in the next if statement (line 718)

  if (NILP (visit) && total > 0)
    prepare_to_modify_buffer (PT, PT, NULL);

which as far as I can tell calls lock_file on the underlying file.
Any other suggestions/ideas?  

--Boris

PS. I can see the comment in fileio.c regarding /proc and can guess
that this sometimes might come in handy, but I do not see why reading
a regular zero-byte file should force a modification and/or locking of
the current buffer.  But if I am right, I do not see how reading a
zero-byte file can EVER work right.  Richard said he tried some casual
tests and it seems to work.  I just tried creating a file qqqq in /tmp,
visiting it, and doing (insert-file-contents "/var/mail/whatever") and
lo and behold, a lock file for /tmp/qqqq showed up!  Just tried it
again with /tmp/empty in place of /var/mail/whatever---same effect.
Does it mean that 0-size insertion is just broken on my machine
(Solaris 5.7, gcc 3.1)?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]