Subject: c-ares small bug fix

c-ares small bug fix

From: Ashish Sharma <asharma_at_rediffmail.com>
Date: 6 Mar 2007 13:07:40 -0000

Hi Daniel I am using the ares library (1.1.1) in my application code as a complete dns client; Thanks for creating such a useful utility. I found the undermentioned problem in the latest code base (1.3.2 release) as well and have solved it. I had mailed you earlier (2-3 weeks aback) but have not got a responce yet, so i thought that you might have missed my mail. Please revert back soon. Problem ------- During testing of my application code I found that the recv system calls hangs in ICMP scenarios when ICMP message is not actually received due to network issue. The exact test scenario is when the destination is not reachable and ICMP is not received on my application box after timeout the request is send to the next server. The receive for the second requests hangs, the backtrace of the hanging thread is shown below #4 0x400291d8 in recv () from /lib/tls/libpthread.so.0 #5 0x08375181 in read_udp_packets (channel=0x8682868, read_fds=0x721459e0, now=1164892770) at ares_process.c:242 #6 0x08374c72 in ares_process (channel=0x8682868, read_fds=0x721459e0, write_fds=0x72145960) at ares_process.c:60 #7 0x0835f667 in aresReceiveDNSResponse (arg=0x0) at ../aresapi.c:346 #8 0x082e334d in ThreadFn (arg1=0x86828b8) at /home/ashish/bugs/LNP/patch/4.0c3-21/common/thutils.c:292 #9 0x400249dd in start_thread () from /lib/tls/libpthread.so.0 #10 0x4010affa in clone () from /lib/tls/libc.so.6 - Ares release that I am using is 1.1.1 so simply making the sockets non-blocking (my first guess) does not addresses the problem. - I check this on the latest 1.3.2 release the problem was reproducable Solution -------- The problem was traced to the function read_udp_packet in the ares_process.c file, when cound <= 0 for the recv system call ( when ICMP is not received) we call handle_error and close this open socket and send the request to the next server and we take a new socket id for the new send. It so happens in this process that the socket fd that was freed in close is taken up open call. But in this call flow we did not clear this file discriptor. So FD_CLR(server->udp_socket, read_fds) call before handle_error in the read_udp_packet solves this issue. -------------- Just wanted to inform you that we have developed a complete session border controller (SBC) and we have sucessfully integrated ares client in our code base and are effectively using it as a DNS & ENUM client. It works jst great.. Good work Daniel !!!! Thanks Ashish
Received on 2007-03-06