Skip to content
Snippets Groups Projects
Commit 989ec98e authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

modified and corrected test 506

parent d262d0a6
No related branches found
No related tags found
No related merge requests found
......@@ -63,73 +63,79 @@ CURL_LOCK_DATA_COOKIE
CURL_LOCK_DATA_DNS
*** run 1
CURLOPT_SHARE
lock: share <Pigs in space>
unlock: share <Pigs in space>
lock: share <Pigs in space>: 0
unlock: share <Pigs in space>: 1
PERFORM
lock: dns <Pigs in space>
unlock: dns <Pigs in space>
lock: dns <Pigs in space>
unlock: dns <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: dns <Pigs in space>: 2
unlock: dns <Pigs in space>: 3
lock: dns <Pigs in space>: 4
unlock: dns <Pigs in space>: 5
lock: cookie <Pigs in space>: 6
unlock: cookie <Pigs in space>: 7
lock: cookie <Pigs in space>: 8
unlock: cookie <Pigs in space>: 9
lock: cookie <Pigs in space>: 10
unlock: cookie <Pigs in space>: 11
lock: cookie <Pigs in space>: 12
unlock: cookie <Pigs in space>: 13
run 1: set cookie 1, 2 and 3
lock: dns <Pigs in space>
unlock: dns <Pigs in space>
lock: dns <Pigs in space>: 14
unlock: dns <Pigs in space>: 15
lock: dns <Pigs in space>: 16
unlock: dns <Pigs in space>: 17
CLEANUP
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>: 18
unlock: cookie <Pigs in space>: 19
*** run 2
CURLOPT_SHARE
lock: share <Pigs in space>
unlock: share <Pigs in space>
lock: share <Pigs in space>: 20
unlock: share <Pigs in space>: 21
PERFORM
lock: dns <Pigs in space>
unlock: dns <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: dns <Pigs in space>: 22
unlock: dns <Pigs in space>: 23
lock: cookie <Pigs in space>: 24
unlock: cookie <Pigs in space>: 25
lock: cookie <Pigs in space>: 26
unlock: cookie <Pigs in space>: 27
lock: cookie <Pigs in space>: 28
unlock: cookie <Pigs in space>: 29
run 2: set cookie 4 and 5
lock: dns <Pigs in space>
unlock: dns <Pigs in space>
lock: dns <Pigs in space>: 30
unlock: dns <Pigs in space>: 31
lock: dns <Pigs in space>: 32
unlock: dns <Pigs in space>: 33
CLEANUP
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>: 34
unlock: cookie <Pigs in space>: 35
*** run 3
CURLOPT_SHARE
lock: share <Pigs in space>
unlock: share <Pigs in space>
lock: share <Pigs in space>: 36
unlock: share <Pigs in space>: 37
CURLOPT_COOKIEJAR
PERFORM
lock: dns <Pigs in space>
unlock: dns <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: dns <Pigs in space>: 38
unlock: dns <Pigs in space>: 39
lock: cookie <Pigs in space>: 40
unlock: cookie <Pigs in space>: 41
lock: cookie <Pigs in space>: 42
unlock: cookie <Pigs in space>: 43
lock: cookie <Pigs in space>: 44
unlock: cookie <Pigs in space>: 45
run 3: overwrite cookie 1 and 4
lock: dns <Pigs in space>
unlock: dns <Pigs in space>
lock: dns <Pigs in space>: 46
unlock: dns <Pigs in space>: 47
lock: dns <Pigs in space>: 48
unlock: dns <Pigs in space>: 49
try SHARE_CLEANUP...
lock: share <Pigs in space>
unlock: share <Pigs in space>
lock: share <Pigs in space>: 50
unlock: share <Pigs in space>: 51
SHARE_CLEANUP failed, correct
CLEANUP
lock: cookie <Pigs in space>
unlock: cookie <Pigs in space>
lock: cookie <Pigs in space>: 52
unlock: cookie <Pigs in space>: 53
SHARE_CLEANUP
lock: share <Pigs in space>
unlock: share <Pigs in space>
lock: share <Pigs in space>: 54
unlock: share <Pigs in space>: 55
GLOBAL_CLEANUP
</stdout>
<stderr>
......
......@@ -14,20 +14,27 @@ struct Tdata {
char *url;
};
struct userdata {
char *text;
int counter;
};
/* lock callback */
void lock(CURL *handle, curl_lock_data data, curl_lock_access access,
void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
(void)access;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
what = "share ";
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns ";
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
......@@ -36,20 +43,22 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access,
fprintf(stderr, "lock: no such data: %d\n",data);
return;
}
printf("lock: %s <%s>\n", what, (char *)useptr);
printf("lock: %-6s <%s>: %d\n", what, user->text, user->counter);
user->counter++;
}
/* unlock callback */
void unlock(CURL *handle, curl_lock_data data, void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:
what = "share ";
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns ";
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
......@@ -58,7 +67,8 @@ void unlock(CURL *handle, curl_lock_data data, void *useptr )
fprintf(stderr, "unlock: no such data: %d\n",data);
return;
}
printf("unlock: %s <%s>\n", what, (char *)useptr);
printf("unlock: %-6s <%s>: %d\n", what, user->text, user->counter);
user->counter++;
}
......@@ -127,6 +137,10 @@ CURLcode test(char *URL)
CURLSH *share;
struct curl_slist *headers;
int i;
struct userdata user;
user.text = (char *)"Pigs in space";
user.counter = 0;
printf( "GLOBAL_INIT\n" );
curl_global_init( CURL_GLOBAL_ALL );
......@@ -136,7 +150,7 @@ CURLcode test(char *URL)
share = curl_share_init();
curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock);
curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock);
curl_share_setopt( share, CURLSHOPT_USERDATA, "Pigs in space");
curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
printf( "CURL_LOCK_DATA_COOKIE\n" );
curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
printf( "CURL_LOCK_DATA_DNS\n" );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment