diff options
| author | Paul Eggert | 2013-03-13 11:42:22 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-03-13 11:42:22 -0700 |
| commit | 47d7532e093db8a5068a40c587915121ffaaad18 (patch) | |
| tree | a99ea6eca34ea0e9c8d6e8a8d6291833ce27dca5 /lib-src | |
| parent | c7ffccaf17d63cefd34bef0a9becc4e68df3b115 (diff) | |
| download | emacs-47d7532e093db8a5068a40c587915121ffaaad18.tar.gz emacs-47d7532e093db8a5068a40c587915121ffaaad18.zip | |
File synchronization fixes.
* admin/CPP-DEFINES (BSD_SYSTEM, HAVE_FSYNC): Remove.
* admin/merge-gnulib (GNULIB_MODULES): Add fsync, fdatasync.
* configure.ac (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
(fsync): Remove check; now done by gnulib.
* lib/fdatasync.c, lib/fsync.c, m4/fdatasync.m4, m4/fsync.m4:
New files, from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib-src/Makefile.in (LIB_FDATASYNC): New macro.
(emacsclient${EXEEXT}): Use it.
* lib-src/emacsclient.c (main): Use fdatasync, not fsync, since we don't
care about metadata. Keep trying if interrupted.
* lib-src/movemail.c (main, popmail): Don't worry about BSD_SYSTEM, since
fsync is available everywhere (or there is a substitute). Don't
report an error if fsync returns EINVAL.
* nt/inc/ms-w32.h (fdatasync): New macro, suggested by Eli Zaretskii.
* src/Makefile.in (LIB_FDATASYNC): New macro.
(LIBES): Use it.
* src/conf_post.h (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
* src/fileio.c (Fwrite_region, write_region_inhibit_fsync):
Don't worry about HAVE_FSYNC, since a substitute fsync is
available if the system lacks one.
(Fwrite_regin): Retry fsync if interrupted.
Fixes: debbugs:13944
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 9 | ||||
| -rw-r--r-- | lib-src/Makefile.in | 4 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 6 | ||||
| -rw-r--r-- | lib-src/movemail.c | 17 |
4 files changed, 20 insertions, 16 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 6ecfb283ff6..d8ec0579422 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2013-03-13 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2013-03-13 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | File synchronization fixes (Bug#13944). | ||
| 4 | * Makefile.in (LIB_FDATASYNC): New macro. | ||
| 5 | (emacsclient${EXEEXT}): Use it. | ||
| 6 | * emacsclient.c (main): Use fdatasync, not fsync, since we don't | ||
| 7 | care about metadata. Keep trying if interrupted. | ||
| 8 | * movemail.c (main, popmail): Don't worry about BSD_SYSTEM, since | ||
| 9 | fsync is available everywhere (or there is a substitute). Don't | ||
| 10 | report an error if fsync returns EINVAL. | ||
| 11 | |||
| 3 | Static checking by Sun C 5.12. | 12 | Static checking by Sun C 5.12. |
| 4 | * etags.c (analyse_regex): Omit unreachable code. | 13 | * etags.c (analyse_regex): Omit unreachable code. |
| 5 | 14 | ||
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 8a6960ee2fe..7069af9767a 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in | |||
| @@ -161,6 +161,8 @@ LIBRESOLV=@LIBRESOLV@ | |||
| 161 | LIBS_MAIL=@LIBS_MAIL@ | 161 | LIBS_MAIL=@LIBS_MAIL@ |
| 162 | ## empty or -lrt or -lposix4 if HAVE_CLOCK_GETTIME | 162 | ## empty or -lrt or -lposix4 if HAVE_CLOCK_GETTIME |
| 163 | LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ | 163 | LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ |
| 164 | ## empty or -lrt or -lposix4 if HAVE_FDATASYNC | ||
| 165 | LIB_FDATASYNC = @LIB_FDATASYNC@ | ||
| 164 | 166 | ||
| 165 | ## Extra libraries to use when linking movemail. | 167 | ## Extra libraries to use when linking movemail. |
| 166 | LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \ | 168 | LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \ |
| @@ -334,7 +336,7 @@ pop.o: ${srcdir}/pop.c ${srcdir}/../lib/min-max.h $(config_h) | |||
| 334 | emacsclient${EXEEXT}: ${srcdir}/emacsclient.c $(config_h) | 336 | emacsclient${EXEEXT}: ${srcdir}/emacsclient.c $(config_h) |
| 335 | $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c \ | 337 | $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c \ |
| 336 | -DVERSION="\"${version}\"" \ | 338 | -DVERSION="\"${version}\"" \ |
| 337 | $(LOADLIBES) -o emacsclient | 339 | $(LOADLIBES) $(LIB_FDATASYNC) -o emacsclient |
| 338 | 340 | ||
| 339 | hexl${EXEEXT}: ${srcdir}/hexl.c $(config_h) | 341 | hexl${EXEEXT}: ${srcdir}/hexl.c $(config_h) |
| 340 | $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl | 342 | $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 6feaf18ba60..898e8d69b07 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -1724,7 +1724,8 @@ main (int argc, char **argv) | |||
| 1724 | needlf = 2; | 1724 | needlf = 2; |
| 1725 | } | 1725 | } |
| 1726 | fflush (stdout); | 1726 | fflush (stdout); |
| 1727 | fsync (1); | 1727 | while (fdatasync (1) != 0 && errno == EINTR) |
| 1728 | continue; | ||
| 1728 | 1729 | ||
| 1729 | /* Now, wait for an answer and print any messages. */ | 1730 | /* Now, wait for an answer and print any messages. */ |
| 1730 | while (exit_status == EXIT_SUCCESS) | 1731 | while (exit_status == EXIT_SUCCESS) |
| @@ -1825,7 +1826,8 @@ main (int argc, char **argv) | |||
| 1825 | if (needlf) | 1826 | if (needlf) |
| 1826 | printf ("\n"); | 1827 | printf ("\n"); |
| 1827 | fflush (stdout); | 1828 | fflush (stdout); |
| 1828 | fsync (1); | 1829 | while (fdatasync (1) != 0 && errno == EINTR) |
| 1830 | continue; | ||
| 1829 | 1831 | ||
| 1830 | if (rl < 0) | 1832 | if (rl < 0) |
| 1831 | exit_status = EXIT_FAILURE; | 1833 | exit_status = EXIT_FAILURE; |
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 190937d762b..81ac8aa187c 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -466,10 +466,8 @@ main (int argc, char **argv) | |||
| 466 | } | 466 | } |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | #ifdef BSD_SYSTEM | 469 | if (fsync (outdesc) != 0 && errno != EINVAL) |
| 470 | if (fsync (outdesc) < 0) | ||
| 471 | pfatal_and_delete (outname); | 470 | pfatal_and_delete (outname); |
| 472 | #endif | ||
| 473 | 471 | ||
| 474 | /* Prevent symlink attacks truncating other users' mailboxes */ | 472 | /* Prevent symlink attacks truncating other users' mailboxes */ |
| 475 | if (setregid (-1, real_gid) < 0) | 473 | if (setregid (-1, real_gid) < 0) |
| @@ -750,21 +748,14 @@ popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse | |||
| 750 | } | 748 | } |
| 751 | } | 749 | } |
| 752 | 750 | ||
| 753 | /* On AFS, a call to write only modifies the file in the local | 751 | if (fsync (mbfi) != 0 && errno != EINVAL) |
| 754 | * workstation's AFS cache. The changes are not written to the server | ||
| 755 | * until a call to fsync or close is made. Users with AFS home | ||
| 756 | * directories have lost mail when over quota because these checks were | ||
| 757 | * not made in previous versions of movemail. */ | ||
| 758 | |||
| 759 | #ifdef BSD_SYSTEM | ||
| 760 | if (fsync (mbfi) < 0) | ||
| 761 | { | 752 | { |
| 762 | error ("Error in fsync: %s", strerror (errno), 0); | 753 | error ("Error in fsync: %s", strerror (errno), 0); |
| 754 | close (mbfi); | ||
| 763 | return EXIT_FAILURE; | 755 | return EXIT_FAILURE; |
| 764 | } | 756 | } |
| 765 | #endif | ||
| 766 | 757 | ||
| 767 | if (close (mbfi) == -1) | 758 | if (close (mbfi) != 0) |
| 768 | { | 759 | { |
| 769 | error ("Error in close: %s", strerror (errno), 0); | 760 | error ("Error in close: %s", strerror (errno), 0); |
| 770 | return EXIT_FAILURE; | 761 | return EXIT_FAILURE; |