Changeset 5427:50cc55e95be6
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5425
|
r5427
|
|
| 1 | | 2008-06-25 23:13 -0700 Brendan Cully <brendan@kublai.com> (d2134eced31b) |
| | 1 | 2008-06-26 00:18 -0700 Brendan Cully <brendan@kublai.com> (5d46ad49d04a) |
| | 2 | |
| | 3 | * mh.c: fsync maildir/mh messages on commit. Closes #2962. |
| | 4 | |
| | 5 | 2008-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. |
| 2 | 10 | |
| 3 | 11 | * init.h: Make $move default to no instead of ask-no. Closes #2945. |
-
|
r5328
|
r5427
|
|
| 210 | 210 | } |
| 211 | 211 | |
| | 212 | int 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 | |
| 212 | 231 | char *safe_strdup (const char *s) |
| 213 | 232 | { |
-
|
r5308
|
r5427
|
|
| 171 | 171 | int safe_symlink (const char *, const char *); |
| 172 | 172 | int safe_fclose (FILE **); |
| | 173 | int safe_fsync_close (FILE **); |
| 173 | 174 | |
| 174 | 175 | size_t mutt_quote_filename (char *, size_t, const char *); |
-
|
r5426
|
r5427
|
|
| 1312 | 1312 | char *s; |
| 1313 | 1313 | |
| 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")); |
| 1317 | 1317 | return -1; |
| 1318 | 1318 | } |
| 1319 | | if (safe_fclose (&msg->fp) != 0) |
| 1320 | | return -1; |
| 1321 | 1319 | |
| 1322 | 1320 | /* extract the subdir */ |
| … |
… |
|
| 1392 | 1390 | char tmp[16]; |
| 1393 | 1391 | |
| 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")); |
| 1397 | 1395 | return -1; |
| 1398 | 1396 | } |
| 1399 | | if (safe_fclose (&msg->fp) != 0) |
| 1400 | | return -1; |
| 1401 | 1397 | |
| 1402 | 1398 | if ((dirp = opendir (ctx->path)) == NULL) |