1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

Dirk Manske's bugfix for the share stuff

This commit is contained in:
Daniel Stenberg 2003-08-11 06:30:02 +00:00
parent 5dadbd094e
commit 8dd069604c

View File

@ -39,8 +39,10 @@ curl_share_init(void)
{ {
struct Curl_share *share = struct Curl_share *share =
(struct Curl_share *)malloc(sizeof(struct Curl_share)); (struct Curl_share *)malloc(sizeof(struct Curl_share));
if (share) if (share) {
memset (share, 0, sizeof(struct Curl_share)); memset (share, 0, sizeof(struct Curl_share));
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
}
return share; return share;
} }
@ -145,11 +147,21 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
return CURLSHE_OK; return CURLSHE_OK;
} }
CURLSHcode curl_share_cleanup(CURLSH *sh) CURLSHcode
curl_share_cleanup(CURLSH *sh)
{ {
struct Curl_share *share = (struct Curl_share *)sh; struct Curl_share *share = (struct Curl_share *)sh;
if (share->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; return CURLSHE_IN_USE;
}
if(share->hostcache) if(share->hostcache)
Curl_hash_destroy(share->hostcache); Curl_hash_destroy(share->hostcache);
@ -157,6 +169,7 @@ CURLSHcode curl_share_cleanup(CURLSH *sh)
if(share->cookies) if(share->cookies)
Curl_cookie_cleanup(share->cookies); Curl_cookie_cleanup(share->cookies);
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
free (share); free (share);
return CURLSHE_OK; return CURLSHE_OK;