[libvirt] [PATCH] esx: Fix race condition in esxVI_EnsureSession
Eric Blake
eblake at redhat.com
Mon May 16 17:50:21 UTC 2011
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/
> 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.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110516/da52a984/attachment-0001.sig>
More information about the libvir-list
mailing list