From: Remi Gacogne Date: Thu, 23 May 2019 10:41:32 +0000 (+0200) Subject: rec: Remove useless accounting of FDs in the UDPClientSocks class X-Git-Tag: dnsdist-1.4.0-beta1~18^2~2 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fpdns.git;a=commitdiff_plain;h=2bee9b7c896f0d12cd7f81cbea8fac1cf7b988f0 rec: Remove useless accounting of FDs in the UDPClientSocks class --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 1e171080c0..af5cde11ad 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -535,9 +535,6 @@ public: { } - typedef set socks_t; - socks_t d_socks; - // returning -2 means: temporary OS error (ie, out of files), -1 means error related to remote int getSocket(const ComboAddress& toaddr, int* fd) { @@ -560,43 +557,32 @@ public: return -1; } - d_socks.insert(*fd); d_numsocks++; return 0; } - void returnSocket(int fd) - { - socks_t::iterator i=d_socks.find(fd); - if(i==d_socks.end()) { - throw PDNSException("Trying to return a socket (fd="+std::to_string(fd)+") not in the pool"); - } - returnSocketLocked(i); - } - // return a socket to the pool, or simply erase it - void returnSocketLocked(socks_t::iterator& i) + void returnSocket(int fd) { - if(i==d_socks.end()) { - throw PDNSException("Trying to return a socket not in the pool"); - } try { - t_fdm->removeReadFD(*i); + t_fdm->removeReadFD(fd); } - catch(FDMultiplexerException& e) { + catch(const FDMultiplexerException& e) { // we sometimes return a socket that has not yet been assigned to t_fdm } + try { - closesocket(*i); + closesocket(fd); } catch(const PDNSException& e) { g_log<