cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re: sharedhandle Curl_resolv_unlock() error!

From: lizhibao <paullee_530_at_sina.com>
Date: Thu, 2 May 2013 09:02:49 +0800

i have initialized the global state using the api "curl_global_init(CURL_GLOBAL_ALL)" before the thread starting.






lizhibao

From: David Strauss
Date: 2013-04-27 03:52
To: paullee_530; libcurl development
Subject: Re: sharedhandle Curl_resolv_unlock() error!
(1) Your backtrace shows you using threads, but you didn't mention
initializing libcurl's global state first, which is required for
thread safety.
(2) Never reply to a full digest as a way to post to a mailing list,
especially if you're starting a brand-new thread.

On Fri, Apr 26, 2013 at 2:58 AM, lizhibao <paullee_530_at_sina.com> wrote:
>
> libcurl/7.30.0
>
> i use libcurl in my app, and set shared handles with
> if (NULL == g_pshare_handle)
> {
> g_pshare_handle = curl_share_init();
> curl_share_setopt(g_pshare_handle, CURLSHOPT_SHARE,
> CURL_LOCK_DATA_DNS);
> }
> and set the opts
> curl_easy_setopt(curl_handle, CURLOPT_SHARE, g_pshare_handle);
> curl_easy_setopt(curl_handle, CURLOPT_DNS_CACHE_TIMEOUT, 60 * 60);
>
> there is core dump, i compile the new libcurl version 7.30.0 with debug
> options.
> and the breaktrace as follow.
> can you tell me, is there some libcurl api using incorrectly?
>
> (gdb) bt
> #0 0x00000031bf6328a5 in raise () from /lib64/libc.so.6
> #1 0x00000031bf634085 in abort () from /lib64/libc.so.6
> #2 0x00000031bf62ba1e in __assert_fail_base () from /lib64/libc.so.6
> #3 0x00000031bf62bae0 in __assert_fail () from /lib64/libc.so.6
> #4 0x00007fc52f71eed7 in Curl_resolv_unlock (data=0x7fc3f40008c8,
> dns=0x7fc4c402d998) at hostip.c:687
> #5 0x00007fc52f743d5a in Curl_done (connp=0x7fc3f4029560, status=CURLE_OK,
> premature=false) at url.c:5410
> #6 0x00007fc52f75f6fe in multi_runsingle (multi=0x7fc3f40174b8, now=...,
> easy=0x7fc3f4029548) at multi.c:1577
> #7 0x00007fc52f75fad5 in curl_multi_perform (multi_handle=0x7fc3f40174b8,
> running_handles=0x7fc50b60b490) at multi.c:1720
> #8 0x00007fc52f754bce in curl_easy_perform (easy=0x7fc3f40008c8) at
> easy.c:475
> #9 0x0000000000405792 in http_task (task=0x7fc4e40c71d0) at
> task_handle.c:549
> #10 0x0000000000402254 in thpool_thread_do (tp_p=0x228e300) at thpool.c:110
> #11 0x00000031bfe07851 in start_thread () from /lib64/libpthread.so.0
> #12 0x00000031bf6e767d in clone () from /lib64/libc.so.6
> (gdb) f 4
> #4 0x00007fc52f71eed7 in Curl_resolv_unlock (data=0x7fc3f40008c8,
> dns=0x7fc4c402d998) at hostip.c:687
> 687 hostip.c: No such file or directory.
> in hostip.c
> (gdb) p dns
> $1 = (struct Curl_dns_entry *) 0x7fc4c402d998
> (gdb) p dns->inuse
> $2 = 0
> (gdb) p dns->timestamp
> $3 = 1366817602
>
>
>
>
> ________________________________
> lizhibao
>
> From: curl-library-request
> Date: 2013-04-25 17:48
> To: curl-library
> Subject: curl-library Digest, Vol 92, Issue 59
> Send curl-library mailing list submissions to
> curl-library_at_cool.haxx.se
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
> or, via email, send a message with subject or body 'help' to
> curl-library-request_at_cool.haxx.se
>
> You can reach the person managing the list at
> curl-library-owner_at_cool.haxx.se
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of curl-library digest..."
>
>
> Today's Topics:
>
> 1. Re: download multiple files through http or https (Nick Zitzmann)
> 2. Re: Regarding SSL error "ssl couldn't create a context "
> (Daniel Stenberg)
> 3. Re: TLS client authentication in curl_darwinssl.c
> (Daniel Stenberg)
> 4. Re: [PATCH] SFTP file listing suggestion (Daniel Stenberg)
> 5. Re: [PATCH] SFTP file listing suggestion (Dan Fandrich)
> 6. How can I download multiple files using http protocol (Aldrich)
> 7. Re: How can I download multiple files using http protocol
> (Nick Zitzmann)
> 8. Re: [PATCH] SFTP file listing suggestion (Daniel Stenberg)
> 9. Re: BUG: free statement in http_negotiate.c giving heap error
> (Arunav Sanyal)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 24 Apr 2013 09:59:34 -0600
> From: Nick Zitzmann <nick_at_chronosnet.com>
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: download multiple files through http or https
> Message-ID: <C7A9C6B2-277B-40AA-B2E1-2488112C0A39_at_chronosnet.com>
> Content-Type: text/plain; charset=us-ascii
>
>
> On Apr 24, 2013, at 2:45 AM, fenghelong <fenghelongnjit_at_gmail.com> wrote:
>
>> I have check out the example in the website,and I followed the example
>> from the libcurl webpage,I found an example to download multiple files
>> using FTP protocol,using FTP protocol I can use the
>> CURLOPT_WILDCARDMATCH option,but my problem is that I want to download
>> multiple files using HTTP or HTTPS protocol,how can I do it?
>
> You have to use a different URL for each file you want to download, since
> unlike FTP, HTTP doesn't have a single method implemented by every server in
> existence that provides a directory listing. But if the server does provide
> a listing somehow (through HTML or WebDAV, for example), then you can fetch
> that listing and parse the results manually.
>
> Nick Zitzmann
> <http://www.chronosnet.com/>
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 24 Apr 2013 22:35:02 +0200 (CEST)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: Regarding SSL error "ssl couldn't create a context "
> Message-ID: <alpine.DEB.2.00.1304242233210.7512_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Mon, 22 Apr 2013, Venkataragavan Vijayakumar wrote:
>
>> One issue comes , while connecting with the HTTPS server using libcurl.
>> the
>> issue is
>>
>> SSL: couldn't create a context:
>> error:140A90F1:lib(20):func(169):reason(241).
>>
>> The problem is , this error is coming only after two times , client get
>> connected and then tear down.
>>
>> That is , for every client HTTPS request , i will create a new connection
>> and then tear it down
>
> Using recent OpenSSL and libcurl versions?
>
> This failure is really early and serious (see lib/ssluse.c:1420). I would
> say
> it indicates something is truly wrong.
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 24 Apr 2013 22:36:48 +0200 (CEST)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: TLS client authentication in curl_darwinssl.c
> Message-ID: <alpine.DEB.2.00.1304242235310.7512_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Mon, 22 Apr 2013, Nick Zitzmann wrote:
>
>> I'm asking for feedback on a proposed change: I've implemented using a
>> client certificate for TLS authentication in the curl_darwinssl code, but
>> I
>> had to make it work differently than the other back-ends, because Apple's
>> Security framework expects the certificate and private key to be in the
>> system or user Keychain instead of in a file on the disk.
>>
>> So when the user uses the --cert option in the curl tool, they would
>> provide
>> the name of the certificate from the Keychain instead of a file, and would
>> not have to provide a private key. I think NSS works the same way, but
>> before I commit, I was wondering if it's okay if we do this if the
>> difference is documented (which I did, in the man pages)?
>
> I think it is fine to do like this, yes. And yes, document the differences
> in
> the suitable places for the options in the man pages.
>
> To me it sounds similar to how the NSS backend does things...
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 24 Apr 2013 23:01:10 +0200 (CEST)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: [PATCH] SFTP file listing suggestion
> Message-ID: <alpine.DEB.2.00.1304242241040.7512_at_tvnag.unkk.fr>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> On Tue, 23 Apr 2013, ????? ???????? wrote:
>
>> here is the patch I've submitted earlier, now made according to the
>> http://curl.haxx.se/dev/contribute.html
>
> First off, I really like this idea and spirit. Thanks! I think we should be
> able to get something like this into libcurl. I believe it should also be
> possible to re-use existing FTP code and make it work like the same way as
> your SFTP approach.
>
> Let me dive straight into my initial remarks on the actual patch:
>
> 1 - I got a build error:
>
> url.c:805:42: error: ISO C forbids assignment between function pointer and
> 'void *' [-Werror=edantic]
>
> 2 - There's no documentation for the new options, and no example code.
> There's
> also no test cases.
>
> 3 - We always have callbacks done in a *FUNCTION and a *DATA pair, and I
> think
> your new one should follow this style too. Do you really think we need a
> CURLOPT_DIRLISTFILES option separately?
>
> 4 - your change for CURLE_QUOTE_ERROR to become
> sftp_libssh2_error_to_CURLE()
> is not really related to the new callback and I would ask you to submit that
> as a separate patch (which we could merge at once)
>
> 5 - I see at least three realloc()s for which you don't check the return
> code
> and thus it will crash libcurl on failure. runtests.pl -t would make it
> obvious if you had test cases...
>
> 6 - to me it feels like there's a lot of repetition of the code lines for
> the
> fail case:
>
> + Curl_safefree(sshc->readdir_line);
> + Curl_safefree(sshc->readdir_filename);
> + Curl_safefree(sshc->readdir_longentry);
> + Curl_fileinfo_dtor(0 /*dummy*/, sshc->readdir_fileinfo);
> + sshc->readdir_fileinfo = 0;
> + state(conn, SSH_SFTP_CLOSE);
> + sshc->actualcode = CURLE_OUT_OF_MEMORY;
>
> 7 - you don't really follow our source indent style all over, but that's
> easily fixed
>
> 8 - why call the new struct member "ftp_list_files" when you don't even
> support this for FTP? The same goes for "ftp_fileinfo_list_callback". I
> would
> suggest something that works indepdently of the protocol being SFTP or FTP
> (or
> whatever protocol that might be able to use the concept).
>
> --
>
> / daniel.haxx.se
>
> ------------------------------
>
> Message: 5
> Date: Wed, 24 Apr 2013 23:30:22 +0200
> From: Dan Fandrich <dan_at_coneharvesters.com>
> To: curl-library_at_cool.haxx.se
> Subject: Re: [PATCH] SFTP file listing suggestion
> Message-ID: <20130424213021.GA5094_at_coneharvesters.com>
> Content-Type: text/plain; charset=iso-8859-1
>
> On Wed, Apr 24, 2013 at 11:01:10PM +0200, Daniel Stenberg wrote:
>> 4 - your change for CURLE_QUOTE_ERROR to become
>> sftp_libssh2_error_to_CURLE()
>> is not really related to the new callback and I would ask you to submit
>> that
>> as a separate patch (which we could merge at once)
>
> I'm not entirely sure about this one. This would make it impossible to tell
> when an error was due to a quote command or when it was due to a subsequent
> file transfer. It's also worth checking if this would affect '*'
> prefixed quote commands.
>
>>>> Dan
>
>
> ------------------------------
>
> Message: 6
> Date: Thu, 25 Apr 2013 10:35:18 +0800
> From: Aldrich <fenghelongnjit_at_gmail.com>
> To: curl-library_at_cool.haxx.se
> Subject: How can I download multiple files using http protocol
> Message-ID: <51789666.3070307_at_gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I want to write a program,downloading multiple files using http protocol
> with libcurl.so I wrote like this.
>
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> #include <curl/curl.h>
> const char *urls[3] = {
> "http://mirrors.163.com/ubuntu-releases/robots.txt",
> "http://mirrors.163.com/ubuntu-releases/favicon.ico",
> "http://mirrors.163.com/ubuntu-releases/HEADER.html"
> };
> #define SIZE sizeof(urls)/sizeof(char*)
> char * find_the_last_symbol(const char* string,int n)
> {
> char *strings = (char*)malloc(n);#include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> #include <curl/curl.h>
> const char *urls[3] = {"http://mirrors.163.com/ubuntu-releases/robots.txt",
> "http://mirrors.163.com/ubuntu-releases/favicon.ico",
> "http://mirrors.163.com/ubuntu-releases/HEADER.html"};
> #define SIZE sizeof(urls)/sizeof(char*)
> char * find_the_last_symbol(const char* string,int n)
> {
> char *strings = (char*)malloc(n);
> strncpy(strings,string,n);
>
> while(strings[n--] != '/');
> ++n;
> char *ptr;
> ptr = &strings[++n];
> free(strings);
>
> return ptr;
> }
> size_t write(char *ptr,size_t size,size_t nmemb,void *userdata)
> {
> return fwrite(ptr,size,nmemb,(FILE*)userdata);
> }
> void init(CURL *curl,const char* url,int n)
> {
>
>
> char *name = find_the_last_symbol(url,n);
> printf("this is in init function open file and write data in
> %s\n",name);
> FILE *filepointer = fopen(name,"w");
> FILE *errorfile = fopen("errorfile","w");
>
> curl_easy_reset(curl);
> curl_easy_setopt(curl,CURLOPT_URL,url);
> curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);
> curl_easy_setopt(curl,CURLOPT_STDERR,errorfile);
> curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write);
> curl_easy_setopt(curl,CURLOPT_WRITEDATA,filepointer);
> curl_easy_perform(curl);
> fclose(filepointer);
> fclose(errorfile);
>
> }
> int main(int argc,char **argv)
> {
> CURL *curl;
> CURLcode res;
> const char **curls = urls;
> FILE *errorfile = fopen("errorfile","w");
> curl = curl_easy_init();
> int i = 0;
> for(;i<SIZE;++i)
> {
> init(curl,urls[i],strlen(urls[i]));
> }
> curl_easy_cleanup(curl);
> return 0;
> }
> strncpy(strings,string,n);
>
> while(strings[n--] != '/');
> ++n;
> char *ptr;
> ptr = &strings[++n];
> free(strings);
>
> return ptr;
> }
> size_t write(char *ptr,size_t size,size_t nmemb,void *userdata)
> {
> return fwrite(ptr,size,nmemb,(FILE*)userdata);
> }
> void init(CURL *curl,const char* url,int n)
> {
>
>
> char *name = find_the_last_symbol(url,n);
> printf("this is in init function open file and write data in
> %s\n",name);
> FILE *filepointer = fopen(name,"w");
> FILE *errorfile = fopen("errorfile","w");
>
> curl_easy_reset(curl);
> curl_easy_setopt(curl,CURLOPT_URL,url);
> curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);
> curl_easy_setopt(curl,CURLOPT_STDERR,errorfile);
> curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write);
> curl_easy_setopt(curl,CURLOPT_WRITEDATA,filepointer);
> curl_easy_perform(curl);
> fclose(filepointer);
> fclose(errorfile);
>
> }
> int main(int argc,char **argv)
> {
> CURL *curl;
> CURLcode res;
> const char **curls = urls;
> FILE *errorfile = fopen("errorfile","w");
> curl = curl_easy_init();
> int i = 0;
> for(;i<SIZE;++i)
> {
> init(curl,urls[i],strlen(urls[i]));
> }
> curl_easy_cleanup(curl);
> return 0;
> }
>
> as the program you can see ,the files` url I have identified,now my
> problem is that if I do not know the files` url,or I just know the web`
> url ,how can download the files in this website,for example the website
> mirrors.163.com,I know using ftp protocol can download multiple
> files.Can anyone help me deal with this problem.
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 24 Apr 2013 22:23:01 -0600
> From: Nick Zitzmann <nick_at_chronosnet.com>
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: How can I download multiple files using http protocol
> Message-ID: <C5E0E362-00D9-4F8E-B3D9-5DD84E5F5AA9_at_chronosnet.com>
> Content-Type: text/plain; charset=us-ascii
>
>
> On Apr 24, 2013, at 8:35 PM, Aldrich <fenghelongnjit_at_gmail.com> wrote:
>
>> as the program you can see ,the files` url I have identified,now my
>> problem is that if I do not know the files` url,or I just know the web` url
>> ,how can download the files in this website,for example the
>> websitemirrors.163.com,I know using ftp protocol can download multiple
>> files.Can anyone help me deal with this problem.
>
> As I said earlier, HTTP, unlike FTP, has no universally-available method of
> getting a directory's contents, so you will have to figure out how to
> download the contents yourself, and then parse the results in code. Some
> sites print directory listings in HTML, some use WebDAV, and most
> intentionally obscure the underlying filesystem. The site you mentioned
> appears to do the first of those three, so your program will have to read
> the data from the Web site, and then parse the HTML for hyperlinks. Once you
> have the hyperlinks, you can use easy handles to fetch them. Good luck.
>
> Nick Zitzmann
> <http://www.chronosnet.com/>
>
>
>
>
>
>
> ------------------------------
>
> Message: 8
> Date: Thu, 25 Apr 2013 08:36:10 +0200 (CEST)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: [PATCH] SFTP file listing suggestion
> Message-ID: <alpine.DEB.2.00.1304250835090.21993_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Wed, 24 Apr 2013, Dan Fandrich wrote:
>
>> On Wed, Apr 24, 2013 at 11:01:10PM +0200, Daniel Stenberg wrote:
>>> 4 - your change for CURLE_QUOTE_ERROR to become
>>> sftp_libssh2_error_to_CURLE()
>>> is not really related to the new callback and I would ask you to submit
>>> that
>>> as a separate patch (which we could merge at once)
>>
>> I'm not entirely sure about this one. This would make it impossible to
>> tell
>> when an error was due to a quote command or when it was due to a
>> subsequent
>> file transfer. It's also worth checking if this would affect '*' prefixed
>> quote commands.
>
> A very good point. We could however use the "real" error code to first make
> libcurl log some details before returning the generic CURLE_QUOTE_ERROR...
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 9
> Date: Thu, 25 Apr 2013 15:18:48 +0530
> From: Arunav Sanyal <arunav.sanyal91_at_gmail.com>
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: BUG: free statement in http_negotiate.c giving heap error
> Message-ID:
> <CAGc_XPKVa_7mDGXyHW00=X7GJgXNx4v+XtxPpqHsZjhF1T6NEw_at_mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I had indented the code properly while sending the email
>
> When i said fail, I meant that the pointer is probably not initialized or
> memory for it is probably never allocated. While the build was successful,
> it was a runtime crash during cleanup operations
>
> if(neg_ctx->server_name != GSS_C_NO_NAME){
> gss_release_name(&minor_status, &neg_ctx->server_name);
> }
> Here the point of failure is the conditional(i.e. the if statement). So i
> am guessing something is wrong with neg_ctx->servername. This cleanup needs
> to be fixed
>
> --
> Arunav Sanyal
> 4th year undergraduate student
> B.E (Hons) Computer Science
> BITS Pilani K.K Birla Goa Campus
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <http://cool.haxx.se/pipermail/curl-library/attachments/20130425/8208b5a6/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> curl-library mailing list
> curl-library_at_cool.haxx.se
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
>
>
> ------------------------------
>
> End of curl-library Digest, Vol 92, Issue 59
> ********************************************
>
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html



--
David Strauss
   | david_at_davidstrauss.net
   | +1 512 577 5827 [mobile]

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-05-02