From 213207da55ca1e23ff4b8098b621d39b9f711022 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Thu, 22 Feb 2018 10:31:19 +0100 Subject: [PATCH] ixfrdist: fix reading nits --- pdns/ixfrdist.cc | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index c6337553ef..7922074bca 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -620,33 +620,15 @@ void handleTCPRequest(int fd, boost::any&) { return; } - char buf[65535]; - int res; - res = recv(cfd, &buf, 2, 0); - if (res != 2) { - if (res == 0) { // Connection is closed - close(cfd); - return; - } - if (res == -1) { - auto savedErrno = errno; - cerr<<"[WARNING] Could not read message from "<(ntohs((buf[0]<<8) + buf[1])), sizeof(buf)); - res = recv(cfd, &buf, toRead, 0); - - if (res == -1) { - auto savedErrno = errno; - cerr<<"[WARNING] Could not read message from "<(sizeof(buf))); + res = readn2WithTimeout(cfd, &buf, toRead, 2); + } catch (runtime_error &e) { + cerr<<"[WARNING] Could not read message from "<