From 4f5e792515148fc96b93b172f1748420d0726a0e Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 6 Jun 2016 21:30:58 +0200 Subject: [PATCH] fix confusing error on TCP/IP disconnect at just the right time (about 'endpoint is not connected') --- pdns/tcpreceiver.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 "<