~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2013-05-23 10:04:17 UTC
  • mfrom: (6437.63.11 2.5)
  • mto: This revision was merged to the branch mainline in revision 6575.
  • Revision ID: john@arbash-meinel.com-20130523100417-i38zikta14q2xdyz
Merge lp:bzr/2.5 tip and move up the changelog items.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2554
2554
else:
2555
2555
    is_local_pid_dead = _posix_is_local_pid_dead
2556
2556
 
 
2557
_maybe_ignored = ['EAGAIN', 'EINTR', 'ENOTSUP', 'EOPNOTSUPP', 'EACCES']
 
2558
_fdatasync_ignored = [getattr(errno, name) for name in _maybe_ignored
 
2559
                      if getattr(errno, name, None) is not None]
 
2560
 
2557
2561
 
2558
2562
def fdatasync(fileno):
2559
2563
    """Flush file contents to disk if possible.
2563
2567
    """
2564
2568
    fn = getattr(os, 'fdatasync', getattr(os, 'fsync', None))
2565
2569
    if fn is not None:
2566
 
        fn(fileno)
 
2570
        try:
 
2571
            fn(fileno)
 
2572
        except IOError, e:
 
2573
            # See bug #1075108, on some platforms fdatasync exists, but can
 
2574
            # raise ENOTSUP. However, we are calling fdatasync to be helpful
 
2575
            # and reduce the chance of corruption-on-powerloss situations. It
 
2576
            # is not a mandatory call, so it is ok to suppress failures.
 
2577
            trace.mutter("ignoring error calling fdatasync: %s" % (e,))
 
2578
            if getattr(e, 'errno', None) not in _fdatasync_ignored:
 
2579
                raise
2567
2580
 
2568
2581
 
2569
2582
def ensure_empty_directory_exists(path, exception_class):