cURL / Mailing Lists / curl-users / Single Mail

curl-users

libcurl and blocking internal DNS resolving

From: AL13N <alien999999999_at_users.sourceforge.net>
Date: Sun, 10 May 2009 14:39:32 +0200

I'm trying to make a non-blocking application using libcurl, and i'm using the
multi interface.

1. i do a select on fds (among which some are curl)
2. the select tells me curl has DATA, so i call curl_multi_perform

for some reason this blocks for at least 10 seconds. i did a backtrace in
those 10 seconds and i got this:

Program received signal SIGINT, Interrupt.
[Switching to Thread 47723727915776 (LWP 29431)]
0x00002b678a815eef in poll () from /lib64/libc.so.6
(gdb) bt
#0 0x00002b678a815eef in poll () from /lib64/libc.so.6
#1 0x00002b678c5d495d in ?? () from /lib64/libresolv.so.2
#2 0x00002b678c5d38e2 in __libc_res_nquery () from /lib64/libresolv.so.2
#3 0x00002b678c5d3b77 in ?? () from /lib64/libresolv.so.2
#4 0x00002b678c5d3d2f in __libc_res_nsearch () from /lib64/libresolv.so.2
#5 0x00002b678c3c94f1 in _nss_dns_gethostbyname3_r ()
from /lib64/libnss_dns.so.2
#6 0x00002b678c3c9754 in _nss_dns_gethostbyname2_r ()
from /lib64/libnss_dns.so.2
#7 0x00002b678a806de7 in ?? () from /lib64/libc.so.6
#8 0x00002b678a808219 in getaddrinfo () from /lib64/libc.so.6
#9 0x00002b678b2f3192 in Curl_getaddrinfo () from /usr/lib64/libcurl.so.4
#10 0x00002b678b2bd809 in Curl_resolv () from /usr/lib64/libcurl.so.4
#11 0x00002b678b2d95ea in ?? () from /usr/lib64/libcurl.so.4
#12 0x00002b678b2d9ae5 in Curl_connect () from /usr/lib64/libcurl.so.4
#13 0x00002b678b2ecc93 in ?? () from /usr/lib64/libcurl.so.4
#14 0x00002b678b2eda23 in curl_multi_perform () from /usr/lib64/libcurl.so.4
#15 0x00002b678a52ab29 in event_fdset_check (events=0x602488,
fd_read=0x7fff207a8300, fd_write=0x7fff207a8280, fd_error=0x7fff207a8200,
nr=0) at event.c:632
#16 0x00002b678a52c436 in events_update (events=0x602488,
max_time=0x7fff207a8530) at event.c:1141
#17 0x00002b678a53a452 in default_checkevents (cache_param=0x602420,
event_param=0x602488, max_time=0x7fff207a8530) at context.c:364
#18 0x00002b678a53bdf1 in libbt_update (context=0x602320,
max_time=0x7fff207a8530) at context.c:849
#19 0x000000000040151e in main (argc=<value optimized out>, argv=<value
optimized out>) at btget.c:179

it seems to block in a poll request which is performed by the getaddrinfo.

I know my local DNS is failing, that is not the problem. the problem is that
it should resolve non-blocking too.

How can i achieve this? is there something i can do?

i don't want my application hanging on DNS resolving, but rather telling me
later on, that it has a problem. my application does more than one thing, and
if DNS is failing for one URL (i'm handling more than 20 urls, some of them
with an IP address), i don't want the other stopping.

Thanks in advance,

AL13N

-- 
AL13N is my name and head-biting is my game.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-05-10