merge-sync: handle PyPy syncfs fail, bug #446610
authorZac Medico <zmedico@gentoo.org>
Thu, 27 Dec 2012 03:10:16 +0000 (19:10 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 27 Dec 2012 03:10:16 +0000 (19:10 -0800)
pym/portage/dbapi/vartree.py

index 25128bf324796819a74b525bacff3d38c2b2b529..840e796f1e72156cc6f9c569c6aa9a959015e7b0 100644 (file)
@@ -4731,15 +4731,10 @@ class dblink(object):
                        "merge-sync" not in self.settings.features:
                        return
 
+               syncfs_failed = False
                syncfs = _get_syncfs()
-               if syncfs is None:
-                       try:
-                               proc = subprocess.Popen(["sync"])
-                       except EnvironmentError:
-                               pass
-                       else:
-                               proc.wait()
-               else:
+
+               if syncfs is not None:
                        for path in self._device_path_map.values():
                                if path is False:
                                        continue
@@ -4749,12 +4744,22 @@ class dblink(object):
                                        pass
                                else:
                                        try:
-                                               syncfs(fd)
+                                               if syncfs(fd) != 0:
+                                                       # Happens with PyPy (bug #446610)
+                                                       syncfs_failed = True
                                        except OSError:
                                                pass
                                        finally:
                                                os.close(fd)
 
+               if syncfs is None or syncfs_failed:
+                       try:
+                               proc = subprocess.Popen(["sync"])
+                       except EnvironmentError:
+                               pass
+                       else:
+                               proc.wait()
+
        def merge(self, mergeroot, inforoot, myroot=None, myebuild=None, cleanup=0,
                mydbapi=None, prev_mtimes=None, counter=None):
                """