cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: how to write the lock funcition in share interface

From: Yi Li <Michael.li_at_playstarmusic.com>
Date: Thu, 19 Jan 2006 15:38:43 -0700

Daniel Stenberg wrote:

> On Wed, 18 Jan 2006, Yi Li wrote:
>
>> my question is
>> what is the data and access in
>>
>> void lock_function(CURL *handle, curl_lock_data data,
>> curl_lock_access access, void *userptr);
>
>
> Allow me to quote the curl_share_setopt() man page:
>
> data defines what data libcurl wants to lock, and you must make
> sure that only one lock is given at any time for each kind of
> data.
>
> access defines what access type libcurl wants, shared or single.
>
>> Could some one give a simple exampe code for share interface please?
>
>
> Sorry. I don't know of any such example, other than the lib506.c file
> from the test suite...
>

I witten a program to use share interface in multi_thread environment.

the gdb error is :

*** glibc detected *** /home/eBBadmin/crawler_file/crawler: double free
or corruption (fasttop): 0xb56178f8 ***
======= Backtrace: =========
/lib/libc.so.6[0x46b424]
/lib/libc.so.6(__libc_free+0x77)[0x46b95f]
/usr/lib/libcurl.so.3[0x612fbb]
/usr/lib/libcurl.so.3(Curl_llist_remove+0x4b)[0x612eb1]
/usr/lib/libcurl.so.3(Curl_hash_clean_with_criterium+0x6f)[0 x6133d4]
/usr/lib/libcurl.so.3(Curl_hostcache_prune+0x79)[0x5f4e94]
/usr/lib/libcurl.so.3(Curl_disconnect+0x29)[0x6025b7]
/usr/lib/libcurl.so.3[0x60408e]
/usr/lib/libcurl.so.3(Curl_connect+0x75f)[0x605093]
/usr/lib/libcurl.so.3[0x60f074]
/usr/lib/libcurl.so.3(Curl_perform+0xe3)[0x611311]
/usr/lib/libcurl.so.3(curl_easy_perform+0x36)[0x6118f1]
/home/eBBadmin/crawler_file/crawler(__gxx_personality_v0+0x3 a1)[0x80493ad]
/lib/libpthread.so.0[0x57ab80]
/lib/libc.so.6(__clone+0x5e)[0x4d2dee]
======= Memory map: ========

Program received signal SIGABRT, Aborted.
[Switching to Thread -1409422416 (LWP 16135)]
0x00541402 in __kernel_vsyscall ()
(gdb) where
#0 0x00541402 in __kernel_vsyscall ()
#1 0x004301f8 in raise () from /lib/libc.so.6
#2 0x00431948 in abort () from /lib/libc.so.6
#3 0x0046552a in __libc_message () from /lib/libc.so.6
#4 0x0046b424 in _int_free () from /lib/libc.so.6
#5 0x0046b95f in free () from /lib/libc.so.6
#6 0x00612fbb in Curl_llist_destroy ()
   from /usr/lib/libcurl.so.3
#7 0x00612eb1 in Curl_llist_remove ()
   from /usr/lib/libcurl.so.3
#8 0x006133d4 in Curl_hash_clean_with_criterium ()
   from /usr/lib/libcurl.so.3
#9 0x005f4e94 in Curl_hostcache_prune ()
   from /usr/lib/libcurl.so.3
#10 0x006025b7 in Curl_disconnect ()
   from /usr/lib/libcurl.so.3
#11 0x0060408e in Curl_setopt () from /usr/lib/libcurl.so.3
#12 0x00605093 in Curl_connect ()
   from /usr/lib/libcurl.so.3

I'm not sure if I writen the program correctly. the attachment is the
program.

Received on 2006-01-19