From 730801d955144f89ddba710b07840f0266861844 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Wed, 3 Feb 2010 17:19:39 +0100 Subject: [PATCH] Another fork() log locking cleanup in file creation 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/util.c b/src/util/util.c index 327ed8a153..7e0cd508ce 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -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'"),