Changeset 5427:50cc55e95be6

Show
Ignore:
Timestamp:
2008-06-26 12:15:18 (5 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
HEAD
Message:

fflush before fsync and close. Closes #2962 again.

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5425 r5427  
    1 2008-06-25 23:13 -0700  Brendan Cully  <brendan@kublai.com>  (d2134eced31b) 
     12008-06-26 00:18 -0700  Brendan Cully  <brendan@kublai.com>  (5d46ad49d04a) 
     2 
     3        * mh.c: fsync maildir/mh messages on commit. Closes #2962. 
     4 
     52008-06-25 23:40 -0700  Brendan Cully  <brendan@kublai.com>  (32374c911c6c) 
     6 
     7        * smime.c: Check S/MIME signing ID exists before attempting to use 
     8        it. Closes #3069. Also make (s)ign automatically ask for a key if 
     9        no default is defined. 
    210 
    311        * init.h: Make $move default to no instead of ask-no. Closes #2945. 
  • lib.c

    r5328 r5427  
    210210} 
    211211 
     212int safe_fsync_close (FILE **f) 
     213{ 
     214  int r = 0; 
     215 
     216  if (*f) 
     217  { 
     218    if (fflush (*f) || fsync (fileno (*f))) 
     219    { 
     220      r = -1; 
     221      fclose (*f); 
     222    } 
     223    else 
     224      r = fclose(*f); 
     225    *f = NULL; 
     226  } 
     227 
     228  return r; 
     229} 
     230 
    212231char *safe_strdup (const char *s) 
    213232{ 
  • lib.h

    r5308 r5427  
    171171int safe_symlink (const char *, const char *); 
    172172int safe_fclose (FILE **); 
     173int safe_fsync_close (FILE **); 
    173174 
    174175size_t mutt_quote_filename (char *, size_t, const char *); 
  • mh.c

    r5426 r5427  
    13121312  char *s; 
    13131313 
    1314   if (msg->fp && fsync(fileno(msg->fp)) < 0) 
    1315   { 
    1316     mutt_perror("Could not flush message to disk"); 
     1314  if (safe_fsync_close (&msg->fp)) 
     1315  { 
     1316    mutt_perror (_("Could not flush message to disk")); 
    13171317    return -1; 
    13181318  } 
    1319   if (safe_fclose (&msg->fp) != 0) 
    1320     return -1; 
    13211319 
    13221320  /* extract the subdir */ 
     
    13921390  char tmp[16]; 
    13931391 
    1394   if (msg->fp && fsync(fileno(msg->fp)) < 0) 
    1395   { 
    1396     mutt_perror("Could not flush message to disk"); 
     1392  if (safe_fsync_close (&msg->fp)) 
     1393  { 
     1394    mutt_perror (_("Could not flush message to disk")); 
    13971395    return -1; 
    13981396  } 
    1399   if (safe_fclose (&msg->fp) != 0) 
    1400     return -1; 
    14011397 
    14021398  if ((dirp = opendir (ctx->path)) == NULL)