[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] util: Remove logging handlers in virExec



On 02/03/2010 03:33 AM, Jiri Denemark wrote:
> ...
>> diff --git a/src/util/util.c b/src/util/util.c
>> index cf1290d..901c0d2 100644
>> --- a/src/util/util.c
>> +++ b/src/util/util.c
>> @@ -415,12 +415,19 @@ __virExec(virConnectPtr conn,
>>          childerr = null;
>>      }
>>  
>> +    /* Ensure we hold the logging lock, to protect child processes
>> +     * from deadlocking on another threads inheirited mutex state */
>> +    virLogLock();
>> +
>>      if ((pid = fork()) < 0) {
>>          virReportSystemError(conn, errno,
>>                               "%s", _("cannot fork child process"));
>>          goto cleanup;
>>      }
>>  
>> +    /* Unlock for both parent and child process */
>> +    virLogUnlock();
>> +
>>      if (pid) { /* parent */
>>          close(null);
>>          if (outfd && *outfd == -1) {
> 
> Hmm, shouldn't we virLogUnlock() even if fork() fails? That is, something
> like:
> 
>     virLogLock();
>     pid = fork();
>     virLogUnlock();
> 
>     if (pid < 0)
>         error;
>     else if (pid)
>         parent;
>     ...
> 
> Jirka
> 

Argh, yes, good call. I'll update the patch and resend.

Thanks,
Cole


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]