Ticket #2962 (closed defect: fixed)

Opened 13 months ago

Last modified 4 months ago

fsync() is not called for messages written to maildir

Reported by: Safari Owned by: mutt-dev
Priority: major Milestone: 1.6
Component: mutt Version:
Keywords: Cc:

Description

It can take as much as 30s (or more) till the OS really flushes the buffers if fsync() is not called.

Besides, maildir format is not reliable if you do not use fsync.

Change History

Changed 5 months ago by brendan

  • milestone set to 1.6

Changed 4 months ago by brendan

  • status changed from new to closed
  • resolution set to fixed

(In [5d46ad49d04a]) fsync maildir/mh messages on commit. Closes #2962.

Changed 4 months ago by Safari

  • status changed from closed to reopened
  • resolution fixed deleted

You should call fflush before fsync. May I suggest something: add function safe_fclose_fsync into lib.c and call safe_fclose_fsync instead of safe_fclose in mh.c.

Then it's also easy to call safe_fclose_fsync when for example saving attachments...

int safe_fclose_fsync (FILE **f)
{
  int r = 0;

  if (*f) {
    if (fflush(*f) == EOF || ((fsync(fileno(*f)) == -1) && errno != EINVAL)) {
      r = -1;
      fclose (*f);
    } else {
      r = fclose (*f);
    }
  }

  *f = NULL;
  return r;
}

Changed 4 months ago by brendan

You're right. I'll push a fix momentarily.

Changed 4 months ago by brendan

  • status changed from reopened to closed
  • resolution set to fixed

(In [50cc55e95be6]) fflush before fsync and close. Closes #2962 again.

Note: See TracTickets for help on using tickets.