]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Another fork() log locking cleanup in file creation
authorLaine Stump <laine@laine.org>
Wed, 3 Feb 2010 16:19:39 +0000 (17:19 +0100)
committerDaniel Veillard <veillard@redhat.com>
Wed, 3 Feb 2010 16:19:39 +0000 (17:19 +0100)
Similar fix as previous one but for fork() usage when creating
a file or directory

* src/util/util.c: virLogLock() and virLogUnlock() around fork()
  in virFileCreate() and virDirCreateSimple()

src/util/util.c

index 327ed8a1531807258a46e983728601369f5815df..7e0cd508ce86cb0f148e127ed707867b746b082c 100644 (file)
@@ -1264,7 +1264,11 @@ int virFileCreate(const char *path, mode_t mode,
      * following dance avoids problems caused by root-squashing
      * NFS servers. */
 
-    if ((pid = fork()) < 0) {
+    virLogLock();
+    pid = fork();
+    virLogUnlock();
+
+    if (pid < 0) {
         ret = errno;
         virReportSystemError(NULL, errno,
                              _("cannot fork o create file '%s'"), path);
@@ -1370,7 +1374,11 @@ int virDirCreate(const char *path, mode_t mode,
         return virDirCreateSimple(path, mode, uid, gid, flags);
     }
 
-    if ((pid = fork()) < 0) {
+    virLogLock();
+    pid = fork();
+    virLogUnlock();
+
+    if (pid < 0) {
         ret = errno;
         virReportSystemError(NULL, errno,
                              _("cannot fork to create directory '%s'"),