[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch to fileio.c
From: |
Fabrice Popineau |
Subject: |
patch to fileio.c |
Date: |
Sun, 26 Oct 2008 16:15:28 +0100 |
Hi,
You should consider adding the following patch. As I reported earlier, the
fd file descriptor may be
closed twice in insert-file-contents. It happens every time a file is
visited and this same file is modified
outside emacs. In this case, you can ask to visit the file again (or emacs
will ask you if you try to save it)
"File foobar.txt changed on disk. Reread from disk? (yes or no)"
The fd file descriptor in this case is closed by emacs_close() at line 3654
and by close_file_unwind() registered at line 3233. When emacs_close(fd) is
reached, the unwind_protect
registered function should be removed. Unfortunately, in the mean time other
stuff has
been put in the unwind_protect stack, so you can't just decrement the
pointer. It can be done
when the handled: label is reached. Hence the flag in my patch.
There was a previous patch may be related to the same problem, but not
fixing it:
2008-09-14 Kenichi Handa <address@hidden>
* fileio.c (Finsert_file_contents): Delete incorrect decrement of
specpdl_ptr.
Best regards,
Fabrice
--- \Mirror\emacs\src\fileio.c 2008-10-16 21:30:49.000000000 +0200
+++ fileio.c 2008-10-26 10:39:11.000000000 +0100
@@ -3141,6 +3141,7 @@
int read_quit = 0;
Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark;
int we_locked_file = 0;
+ int should_remove_unwind_protect = 0;
if (current_buffer->base_buffer && ! NILP (visit))
error ("Cannot do file visiting in an indirect buffer");
@@ -3650,8 +3651,10 @@
if (coding.carryover_bytes > 0)
bcopy (coding.carryover, read_buf, unprocessed);
}
+
UNGCPRO;
emacs_close (fd);
+ should_remove_unwind_protect = 1;
/* At this point, HOW_MUCH should equal TOTAL, or should be <= 0
if we couldn't read the file. */
@@ -4033,6 +4036,9 @@
#endif
handled:
+#if 1
+ if (should_remove_unwind_protect) specpdl_ptr--;
+#endif
if (!NILP (visit))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- patch to fileio.c,
Fabrice Popineau <=