~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2012-09-19 07:58:27 UTC
  • mfrom: (6437.63.9 2.5)
  • mto: This revision was merged to the branch mainline in revision 6563.
  • Revision ID: john@arbash-meinel.com-20120919075827-36b2b042kiaps0d3
Merge bzr-2.5.2 into trunk to get the fixes for ConnectionReset.

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
 
 
2561
2557
 
2562
2558
def fdatasync(fileno):
2563
2559
    """Flush file contents to disk if possible.
2567
2563
    """
2568
2564
    fn = getattr(os, 'fdatasync', getattr(os, 'fsync', None))
2569
2565
    if fn is not None:
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
 
2566
        fn(fileno)
2580
2567
 
2581
2568
 
2582
2569
def ensure_empty_directory_exists(path, exception_class):