Subject: Regarding the C-ARES ---->recv () thread hangs UP

Regarding the C-ARES ---->recv () thread hangs UP

From: Ujjal Raj <ujjal.raj_at_gmail.com>
Date: Tue, 8 May 2007 12:54:32 +0530

Hi
      I am also using the ARES and facing the same problem as stated
by ashish in C-ARES forum
"http://daniel.haxx.se/projects/c-ares/mail/c-ares-archive-2007-03/0002.shtml"
under the subject "c-ares small bug fix"

recv() gets hanged in ares_process.c .my SetUP is as follows :-

     OS---> platform REHL4

     1. No DNS server is configured in resolv.conf and initi has been
modified as requirement for our application .So ares comes up even
resolve.conf is empty/not configured .

     2. The DNS query are send to LoopBacK address .

     3. ICMP message are received from the 127.0.0.1(loopback address).

We have also tried the solution proposed in forum

 "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."

We have added the code FD_CLR(server->udp_socket, read_fds) before
calling handle handle_error where the socket is closed so that it
should get cleared before being used by new socket id where the next
server is used for the DNS query.

Code -----:
previous code :-
                    if (count <= 0)
                                   handle_error(channel, i, now);
changed code :-
                    if (count <= 0)
                     {
                               FD_CLR(server->udp_socket, read_fds);
                            handle_error(channel, i, now);
                      }
But its not working and again it hungs up at recv () call .I am also
trying to see the root cause of it .IT will be of great if anybody
please let me know if any other reason for recv() getting hanged up
in ares_process.c.
We have come across in different forum that Kernel drops the packet
(ICMP error message having wrong checksum ) after notifying select ()
for read fds and before recv() calls , in which case the select()
comes out of the loop and recv() tries to reads data and gets hanged
up, as there is no data to read (packet being dropped by Kernel).We
have captured ethereal data also but all ICMP error have incorrect
checksum(OS-->RHEL) ,hence not helpful to debug the problem .
Any suggestion regarding these will be helpful.

Waiting for your reply.
Thanks & Regards
~Ujjal
Received on 2007-05-08