net: Make poll in InterruptibleRecv only filter for POLLIN events.

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.

Removing POLLOUT matches how select is used when USE_POLL isn't defined.

Github-Pull: #16412
Rebased-From: a52818cc56
Tree-SHA512: eaf466630ba9d2a2a7443c9679c83c2cb13e779a5948f409cddb4c48cf32126ac68f3de48e394f9302e99858efa17cdb14650751a1b55c3b79e8a7507cab352d
This commit is contained in:
tecnovert 2019-07-18 13:04:16 +02:00 committed by Wladimir J. van der Laan
parent 3f76160087
commit 063c8ce7a0
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D

View file

@ -268,7 +268,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);