From: Remi Gacogne Date: Tue, 15 Sep 2020 13:38:53 +0000 (+0200) Subject: dnsdist: Use the more efficient epoll update mechanism X-Git-Tag: auth-4.5.0-alpha0~14^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d46c596e9d316dcc0e13911c7adc7110b894ab06;p=thirdparty%2Fpdns.git dnsdist: Use the more efficient epoll update mechanism --- diff --git a/pdns/dnsdistdist/tcpiohandler-mplexer.hh b/pdns/dnsdistdist/tcpiohandler-mplexer.hh index e0e366dd78..1971a3a152 100644 --- a/pdns/dnsdistdist/tcpiohandler-mplexer.hh +++ b/pdns/dnsdistdist/tcpiohandler-mplexer.hh @@ -50,12 +50,12 @@ public: void update(IOState iostate, FDMultiplexer::callbackfunc_t callback = FDMultiplexer::callbackfunc_t(), FDMultiplexer::funcparam_t callbackData = boost::any(), boost::optional ttd = boost::none) { DEBUGLOG("in "<<__PRETTY_FUNCTION__<<" for fd "<removeReadFD(d_fd); d_currentState = IOState::Done; } - else if (d_currentState == IOState::NeedWrite && iostate != IOState::NeedWrite) { + else if (d_currentState == IOState::NeedWrite && iostate == IOState::Done) { DEBUGLOG(__PRETTY_FUNCTION__<<": remove write FD "<removeWriteFD(d_fd); d_currentState = IOState::Done; @@ -70,18 +70,33 @@ public: return; } + if (d_currentState == IOState::NeedWrite) { + d_mplexer->alterFDToRead(d_fd, callback, callbackData, ttd ? &*ttd : nullptr); + DEBUGLOG(__PRETTY_FUNCTION__<<": alter from write to read FD "<addReadFD(d_fd, callback, callbackData, ttd ? &*ttd : nullptr); + DEBUGLOG(__PRETTY_FUNCTION__<<": add read FD "<addReadFD(d_fd, callback, callbackData, ttd ? &*ttd : nullptr); + } else if (iostate == IOState::NeedWrite) { if (d_currentState == IOState::NeedWrite) { return; } + if (d_currentState == IOState::NeedRead) { + d_mplexer->alterFDToWrite(d_fd, callback, callbackData, ttd ? &*ttd : nullptr); + DEBUGLOG(__PRETTY_FUNCTION__<<": alter from read to write FD "<addWriteFD(d_fd, callback, callbackData, ttd ? &*ttd : nullptr); + DEBUGLOG(__PRETTY_FUNCTION__<<": add write FD "<addWriteFD(d_fd, callback, callbackData, ttd ? &*ttd : nullptr); } else if (iostate == IOState::Done) { d_currentState = IOState::Done;