diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-07-19 17:15:12 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-07-19 17:20:23 +0200 |
commit | f4b1fe7165c84d7ed4ef84cac7e0dc6804973fa5 (patch) | |
tree | b4d87106cc6236e0457c7c857cd7b57fd4c3ab9c | |
parent | c7b7cf299a9e25e054805d1da63eb88f37e4d32e (diff) | |
parent | a52818cc5633494992da7d1dc8fdb04b4a1b7c29 (diff) | |
download | bitcoin-f4b1fe7165c84d7ed4ef84cac7e0dc6804973fa5.tar.xz |
Merge #16412: net: Make poll in InterruptibleRecv only filter for POLLIN events.
a52818cc5633494992da7d1dc8fdb04b4a1b7c29 net: Make poll in InterruptibleRecv only filter for POLLIN events. poll should block until there is data to be read or the timeout expires. (tecnovert)
Pull request description:
poll should block until there is data to be read or the timeout expires.
Filtering for the POLLOUT event causes poll to return immediately which leads to high CPU usage when trying to connect to non-responding peers through tor.
When USE_POLL is not defined select is used with the writefds parameter set to nullptr.
Removing POLLOUT causes the behavior of poll to match that of select.
Fixes: #16004.
ACKs for top commit:
laanwj:
code review ACK a52818cc5633494992da7d1dc8fdb04b4a1b7c29
jonasschnelli:
utACK a52818cc5633494992da7d1dc8fdb04b4a1b7c29
Tree-SHA512: 69934cc14e3327c7ff7f6c5942af8761e865220b2540d74ea1e176adad326307a73860417dddfd32d601b5c0e9e2ada1848bd7e3d27b0b7a9b42f11129af8eb1
-rw-r--r-- | src/netbase.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index 53e5985a0f..6d4738c835 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -347,7 +347,7 @@ static IntrRecvError InterruptibleRecv(uint8_t* data, size_t len, int timeout, c #ifdef USE_POLL struct pollfd pollfd = {}; pollfd.fd = hSocket; - pollfd.events = POLLIN | POLLOUT; + pollfd.events = POLLIN; int nRet = poll(&pollfd, 1, timeout_ms); #else struct timeval tval = MillisToTimeval(timeout_ms); |