From: bert hubert Date: Mon, 6 Jun 2016 19:30:58 +0000 (+0200) Subject: fix confusing error on TCP/IP disconnect at just the right time (about 'endpoint... X-Git-Tag: rec-4.0.0-rc1~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f5e792515148fc96b93b172f1748420d0726a0e;p=pdns fix confusing error on TCP/IP disconnect at just the right time (about 'endpoint is not connected') --- diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 3ac1b9a84..6ade029f6 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -253,7 +253,17 @@ void *TCPNameserver::doConnection(void *data) shared_ptr packet; // Fix gcc-4.0 error (on AMD64) int fd=(int)(long)data; // gotta love C (generates a harmless warning on opteron) + ComboAddress remote; + socklen_t remotelen=sizeof(remote); + pthread_detach(pthread_self()); + if(getpeername(fd, (struct sockaddr *)&remote, &remotelen) < 0) { + L<post(); + closesocket(fd); + return 0; + } + setNonBlocking(fd); try { int mesgsize=65535; @@ -262,12 +272,6 @@ void *TCPNameserver::doConnection(void *data) DLOG(L<<"TCP Connection accepted on fd "<