Unverified Commit 5fe85587 authored by Pavel Pavlov's avatar Pavel Pavlov Committed by Daniel Stenberg
Browse files

cookies: use lock when using CURLINFO_COOKIELIST

Closes #1896
parent c73ebb85
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -1402,7 +1402,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
  return 0;
}

struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
static struct curl_slist *cookie_list(struct Curl_easy *data)
{
  struct curl_slist *list = NULL;
  struct curl_slist *beg;
@@ -1433,6 +1433,15 @@ struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
  return list;
}

struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
{
  struct curl_slist *list;
  Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
  list = cookie_list(data);
  Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
  return list;
}

void Curl_flush_cookies(struct Curl_easy *data, int cleanup)
{
  if(data->set.str[STRING_COOKIEJAR]) {
+9 −7
Original line number Diff line number Diff line
@@ -195,6 +195,8 @@ CURLOPT_COOKIEJAR
CURLOPT_COOKIELIST RELOAD
lock:   cookie [Pigs in space]: 78
unlock: cookie [Pigs in space]: 79
lock:   cookie [Pigs in space]: 80
unlock: cookie [Pigs in space]: 81
loaded cookies:
-----------------
  .host.foo.com	TRUE	/	FALSE	1896263787	injected	yes
@@ -207,17 +209,17 @@ loaded cookies:
  www.host.foo.com	FALSE	/	FALSE	1993463787	test6	six_more
-----------------
try SHARE_CLEANUP...
lock:   share  [Pigs in space]: 80
unlock: share  [Pigs in space]: 81
lock:   share  [Pigs in space]: 82
unlock: share  [Pigs in space]: 83
SHARE_CLEANUP failed, correct
CLEANUP
lock:   cookie [Pigs in space]: 82
unlock: cookie [Pigs in space]: 83
lock:   share  [Pigs in space]: 84
unlock: share  [Pigs in space]: 85
SHARE_CLEANUP
lock:   cookie [Pigs in space]: 84
unlock: cookie [Pigs in space]: 85
lock:   share  [Pigs in space]: 86
unlock: share  [Pigs in space]: 87
SHARE_CLEANUP
lock:   share  [Pigs in space]: 88
unlock: share  [Pigs in space]: 89
GLOBAL_CLEANUP
</stdout>
<stderr>