[reSIProcate] Repost: DNS assert in TransactionState::handle() while unplugging the network cable
hi, all,
If the network connection is unplugged while running,
DNS assert failed at TransactionState.cxx #1282
TransactionState::handle(DnsResult* result)
{
// got a DNS response, so send the current message
StackLog (<< *this << " got DNS result: " <<
*result);
if (mTarget.getType() == UNKNOWN_TRANSPORT)
{
assert(mDnsResult);// failed here, xkd
......
}
Cullen also posted the same problem on 27 Aug, please
refer
http://list.sipfoundry.org/archive/resiprocate-devel/msg01316.html
After digging into the ares library and Dns related
class, I though I have found the reason, :).
In DnsResult::processHost()
void
DnsResult::processHost(int status, struct hostent*
result)
{
StackLog (<< "DnsResult::processHost() " <<
status);
// This function assumes that the A query that
caused this callback
// is the _only_ outstanding DNS query that might
result in a
// callback into this function
if ( mType == Destroyed )
{
destroy();
return;
}
if (status == ARES_SUCCESS)
{
.....
}
else
{
char* errmem=0;
StackLog (<< "Failed async A query: " <<
ares_strerror(status, &errmem));
ares_free_errmem(errmem);
mType = Finished;//xkd-2004-11-25-begin
// Just set the status as Finished, donot delete
or destroy it
// It will be deleted in TransactionState's
destructor after receiving 408 (timeout)
return; //xkd-2004-11-25-end
}
Also I found a mis-consideration in ares_init().
In init_by_defaults()
{
....
num = 0;
pIPAddr = &FixedInfo->DnsServerList;
while ( pIPAddr &&
strlen(pIPAddr->IpAddress.String) > 0)
{
num++;
pIPAddr = pIPAddr ->Next;
}
channel->servers = malloc( (num) *
sizeof(struct server_state));
...
}
It is better to check the value of num, if num is
zero, i.e., no network connection, no DNS server, in
this case it should return error.
kaiduan
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca