aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-08-28 07:37:29 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-08-28 07:37:29 +0000
commit099b62f1246602af876f39f9155ddae2ef909181 (patch)
treef0538cb8cdee8c07c0670f0ff5cc48ac0e64a783 /lib
parent8ce78ca488f589d9b1987e7713f28f9da15cba0f (diff)
- Dengminwen reported that libcurl would lock a (cookie) share twice (without
an unlock in between) for a certain case and that in fact works when using regular windows mutexes but not with pthreads'! Locks should of course not get locked again so this is now fixed. http://curl.haxx.se/mail/lib-2008-08/0422.html
Diffstat (limited to 'lib')
-rw-r--r--lib/url.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/url.c b/lib/url.c
index a70b471b2..da757a377 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -346,14 +346,16 @@ CURLcode Curl_dupset(struct SessionHandle * dst, struct SessionHandle * src)
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
static void flush_cookies(struct SessionHandle *data, int cleanup)
{
- Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
if(data->set.str[STRING_COOKIEJAR]) {
if(data->change.cookielist) {
/* If there is a list of cookie files to read, do it first so that
- we have all the told files read before we write the new jar */
+ we have all the told files read before we write the new jar.
+ Curl_cookie_loadfiles() LOCKS and UNLOCKS the share itself! */
Curl_cookie_loadfiles(data);
}
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
+
/* if we have a destination file for all the cookies to get dumped to */
if(Curl_cookie_output(data->cookies, data->set.str[STRING_COOKIEJAR]))
infof(data, "WARNING: failed to save cookies in %s\n",
@@ -364,6 +366,7 @@ static void flush_cookies(struct SessionHandle *data, int cleanup)
/* since nothing is written, we can just free the list of cookie file
names */
curl_slist_free_all(data->change.cookielist); /* clean up list */
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
}
if(cleanup && (!data->share || (data->cookies != data->share->cookies))) {