1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 16:18:48 -05:00

cookie: avoid mutex deadlock

... by removing the extra mutex locks around th call to
Curl_flush_cookies() which takes care of the locking itself already.

Bug: http://curl.haxx.se/mail/lib-2014-02/0184.html
This commit is contained in:
Yousuke Kimoto 2014-07-14 20:38:18 +02:00 committed by Daniel Stenberg
parent f069b40f9d
commit aa68848451

View File

@ -1169,18 +1169,20 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
if(argptr == NULL) if(argptr == NULL)
break; break;
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
if(Curl_raw_equal(argptr, "ALL")) { if(Curl_raw_equal(argptr, "ALL")) {
/* clear all cookies */ /* clear all cookies */
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_clearall(data->cookies); Curl_cookie_clearall(data->cookies);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
} }
else if(Curl_raw_equal(argptr, "SESS")) { else if(Curl_raw_equal(argptr, "SESS")) {
/* clear session cookies */ /* clear session cookies */
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_clearsess(data->cookies); Curl_cookie_clearsess(data->cookies);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
} }
else if(Curl_raw_equal(argptr, "FLUSH")) { else if(Curl_raw_equal(argptr, "FLUSH")) {
/* flush cookies to file */ /* flush cookies to file, takes care of the locking */
Curl_flush_cookies(data, 0); Curl_flush_cookies(data, 0);
} }
else { else {
@ -1193,6 +1195,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;
} }
else { else {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
if(checkprefix("Set-Cookie:", argptr)) if(checkprefix("Set-Cookie:", argptr))
/* HTTP Header format line */ /* HTTP Header format line */
@ -1202,10 +1205,10 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/* Netscape format line */ /* Netscape format line */
Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL); Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
free(argptr); free(argptr);
} }
} }
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
break; break;
#endif /* CURL_DISABLE_COOKIES */ #endif /* CURL_DISABLE_COOKIES */