From 8dd069604ce80652935215f0e0986cf487e4ac6d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 11 Aug 2003 06:30:02 +0000 Subject: [PATCH] Dirk Manske's bugfix for the share stuff --- lib/share.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/share.c b/lib/share.c index 9b5f79f9e..37acef195 100644 --- a/lib/share.c +++ b/lib/share.c @@ -39,8 +39,10 @@ curl_share_init(void) { struct Curl_share *share = (struct Curl_share *)malloc(sizeof(struct Curl_share)); - if (share) + if (share) { memset (share, 0, sizeof(struct Curl_share)); + share->specifier |= (1<dirty) + + if (share == NULL) + return CURLSHE_INVALID; + + share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE, + share->clientdata); + + if (share->dirty) { + share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); return CURLSHE_IN_USE; + } if(share->hostcache) Curl_hash_destroy(share->hostcache); @@ -157,6 +169,7 @@ CURLSHcode curl_share_cleanup(CURLSH *sh) if(share->cookies) Curl_cookie_cleanup(share->cookies); + share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); free (share); return CURLSHE_OK; @@ -173,7 +186,7 @@ Curl_share_lock(struct SessionHandle *data, curl_lock_data type, return CURLSHE_INVALID; if(share->specifier & (1<lockfunc (data, type, access, share->clientdata); + share->lockfunc(data, type, access, share->clientdata); } /* else if we don't share this, pretend successful lock */