curl-library
Libcurl+c-ares when using the multi interface
Date: Tue, 10 Jun 2008 15:07:13 -0700
So when trying to do a POST (I donıt think it matters POST or GET) with the
multi interface with libcurl from cvs and c-ares (also from cvs) I noticed
the following behavior. Cares will do the blocking I/O to check /etc/hosts
(maybe we can expose the struct ares_options.lookups = "b" as a curl multi
option) then if it doesnıt find the host do the DNS lookup. Libcurl will
provide back via the socket_change_callback that the app should listen for
the DNS lookupıs response. However, once the DNS lookup succeeds it wonıt
tell the client app to stop looking for the DNS lookupıs response like the
way libcurl does for other types of connections. I feel this is a bug and
will dig into the code a little to provide a fix. Thoughts?
Chris
strace: Took out the syscalls that didnıt matter
#check /etc/hosts
0.000089 open("/etc/hosts", O_RDONLY) = 6
0.000104 fstat(6, {st_mode=S_IFREG|0644, st_size=238, ...}) = 0
0.000080 mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaaaaf51000
0.000116 read(6, "# Do not remove the following li"..., 4096) = 238
0.000087 read(6, "", 4096) = 0
0.000044 close(6) = 0
0.000044 munmap(0x2aaaaaf51000, 4096) = 0
#didnıt find it do a DNS lookup
0.000048 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
0.000049 fcntl(6, F_GETFL) = 0x2 (flags O_RDWR)
0.000044 fcntl(6, F_SETFL, O_RDWR|O_NONBLOCK) = 0
0.000046 fcntl(6, F_SETFD, FD_CLOEXEC) = 0
0.000080 connect(6, {sa_family=AF_INET, sin_port=htons(53),
sin_addr=inet_addr("10.18.255.53")}, 16) = 0
0.000056 sendto(6,
"\30\336\1\0\0\1\0\0\0\0\0\0\10megaload\3vip\10facebo"..., 43, MSG_NOSIGNAL,
NULL, 0) = 43
0.000075 poll([{fd=6, events=POLLIN}], 1, 0) = 0
0.000058 epoll_ctl(3, EPOLL_CTL_ADD, 6,
{EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP, {u32=6327216, u64=6327216}}) = 0
0.000059 epoll_wait(3, {{EPOLLIN, {u32=6327216, u64=6327216}}}, 200,
93) = 1
0.000048 poll([{fd=6, events=POLLIN, revents=POLLIN}], 1, 0) = 1
0.000050 recvfrom(6,
"\30\336\205\200\0\1\0\2\0\1\0\1\10megaload\3vip\10facebo"..., 513, 0, NULL,
NULL) = 124
0.000073 close(6) = 0
#DNS lookup succeeded. No idea what the next line is
0.000100 recvfrom(-1, 0x7fffdac51e70, 513, 0, 0, 0) = -1 EBADF (Bad
file descriptor)
#create the socket for the http post
0.000048 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 6
0.000049 fcntl(6, F_GETFL) = 0x2 (flags O_RDWR)
0.000073 fcntl(6, F_SETFL, O_RDWR|O_NONBLOCK) = 0
0.000045 connect(6, {sa_family=AF_INET, sin_port=htons(8082),
sin_addr=inet_addr("10.8.253.108")}, 16) = -1 EINPROGRESS (Operation now in
progress)
0.000089 poll([{fd=6, events=POLLOUT}], 1, 0) = 0
#my epoll_ctl tries to modify fd=6 because it was never told to delete fd=6
0.000070 epoll_ctl(3, EPOLL_CTL_MOD, 6, {EPOLLOUT|EPOLLERR|EPOLLHUP,
{u32=6327216, u64=6327216}}) = -1 ENOENT (No such file or directory)
Received on 2008-06-11