[libvirt] [PATCH] esx: Fix race condition in esxVI_EnsureSession

Matthias Bolte matthias.bolte at googlemail.com
Tue May 17 11:15:22 UTC 2011


2011/5/16 Eric Blake <eblake at redhat.com>:
> On 05/01/2011 01:57 PM, Matthias Bolte wrote:
>> When the session has expired then multiple threads can race while
>> reestablishing it.
>>
>> This race condition is not that critical as it requires a special usage
>> pattern to be triggerd. It can only happen when an application doesn't
>
> s/triggerd/triggered/

Fixed.

>> do API calls for quite some time (the session expires after 30 min
>> inactivity) and then multiple threads doing simultaneous API calls and
>> end up doing simultaneous calls to esxVI_EnsureSession.
>> ---
>>  src/esx/esx_vi.c |   47 +++++++++++++++++++++++++++++++++++------------
>>  src/esx/esx_vi.h |    4 +++-
>>  2 files changed, 38 insertions(+), 13 deletions(-)
>
> C code - I'm back in my element!
>
>> +++ b/src/esx/esx_vi.h
>> @@ -185,6 +185,7 @@ int esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl);
>>   */
>>
>>  struct _esxVI_Context {
>> +    /* All members are used read-only after esxVI_Context_Connect ... */
>>      esxVI_CURL *curl;
>>      char *url;
>>      char *ipAddress;
>> @@ -193,7 +194,8 @@ struct _esxVI_Context {
>>      esxVI_ServiceContent *service;
>>      esxVI_APIVersion apiVersion;
>>      esxVI_ProductVersion productVersion;
>> -    esxVI_UserSession *session;
>> +    esxVI_UserSession *session; /* ... except the session ... */
>> +    virMutexPtr sessionLock; /* ... that is protected by this mutex */
>
> ACK, and thanks for those comments.
>

Thanks, pushed.

Matthias




More information about the libvir-list mailing list