Ticket #192 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

pdns_recursor crashes with "Exception: Error closing socket: Connection reset by peer" message

Reported by: anon Owned by: somebody
Priority: normal Milestone:
Component: component1 Version:
Severity: normal Keywords:
Cc:

Description

I'm running pdns_recursor on FreeBSD 6.3-RELEASE, i386 platform. Suddenly it has stopped working with diagnostics below:

Jul 30 09:09:07 ns pdns_recursor[93705]: Exception: Error closing socket: Connection reset by peer

Digging through the code in file unix_utility.cc reveals this function:


int Utility::closesocket( Utility::sock_t socket ) {

int ret=::close(socket); if(ret < 0)

throw AhuException?("Error closing socket: "+stringerror());

return ret;

}


It seems to me that remote party sends a TCP RST during the small period of time between last recv() from this TCP socket and closing the socket by pdn_recursor, may be due to timer expired. While there is a very small probability for this scenario, it should be handled properly, especially on busy servers, serving hundreds DNS-queries per second.

There are at least three ways to do it:

- call a getsockopt with SO_ERROR option specified just before calling close(). It will clear any error condition on socket, if any. Yes, it will eat more precious cpu resources.

- simple ignore at least ECONNRESET error returned by close(). But it is unclear for me, if socket will be actually closed by some underlying OS code, or not.

- probably. the best way is to handle ECONNRESET after an attempt to close socket by calling getsockopt() and then close() again.

Unfortunately, it will be hard to test any workaround applied, because it is very unlikely, that this bug will occur very often. It took something like three months of running pdns_recursor on six DNS-servers 24x7 to catch one :-)

WBR,

Andrei Poelov

apoelov at mail dot ru

Change History

Changed 4 years ago by ahu

  • status changed from new to closed
  • resolution set to fixed

Fixed in cs 1280, thanks!

Note: See TracTickets for help on using tickets.