From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Evil Boris Newsgroups: gmane.emacs.devel Subject: Re: RMAIL file locking problem? Date: Mon, 09 May 2005 23:03:45 -0400 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1115694172 351 80.91.229.2 (10 May 2005 03:02:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 10 May 2005 03:02:52 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 10 05:02:50 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DVL0u-0000yD-L0 for ged-emacs-devel@m.gmane.org; Tue, 10 May 2005 05:02:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DVL5b-000589-UG for ged-emacs-devel@m.gmane.org; Mon, 09 May 2005 23:07:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DVL4t-0004uU-Qr for emacs-devel@gnu.org; Mon, 09 May 2005 23:06:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DVL4n-0004qj-Su for emacs-devel@gnu.org; Mon, 09 May 2005 23:06:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DVL4n-0004p1-Mu for emacs-devel@gnu.org; Mon, 09 May 2005 23:06:29 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DVL8U-0004d4-AQ for emacs-devel@gnu.org; Mon, 09 May 2005 23:10:18 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DVKv8-0000Wo-8Z for emacs-devel@gnu.org; Tue, 10 May 2005 04:56:30 +0200 Original-Received: from 207-38-193-43.c3-0.wsd-ubr1.qens-wsd.ny.cable.rcn.com ([207.38.193.43]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 May 2005 04:56:30 +0200 Original-Received: from evilborisnet by 207-38-193-43.c3-0.wsd-ubr1.qens-wsd.ny.cable.rcn.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 May 2005 04:56:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 54 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207-38-193-43.c3-0.wsd-ubr1.qens-wsd.ny.cable.rcn.com User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:PVqvEwY2f7ZWf6rVXOvqk68beRg= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:36925 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36925 Richard Stallman 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)?