seeder: Use `poll()` instead of `select()`, if supported
Summary
This is a follow-up to !1386 (merged) in which the base net layer uses poll()
over select()
on certain platforms (currently just Linux).
However, the seeder is still using select()
. select()
suffers from some
design problems in that if it happens to get given an FD > 1024 on
Linux, it won't work. poll()
suffers from no such limitation.
This commit takes the USE_POLL
define, from compat.h
, and if that is
defined, and <poll.h>
is also present at compile-time, then poll()
will
be used instead of select()
.
Also in this MR: tiny nits: prefer const
, use size_t
properly, explicit static_cast
to int
.
Test Plan
ninja bitcoin-seeder check-bitcoin-seeder
- Also start up a seeder on Linux, and ensure it can communicate with nodes that it connects to. Perhaps uncomment the printfs in
seeder/bitcoin.cpp
lines 109-110 to verify it is communicating. -
(Opitional) Compile on a platform that doesn't have
USE_POLL
defined (such as BSD or OSX), or if you only use Linux, just undefine it yourself at the top ofseeder/bitcoin.cpp
, and ensure the seeder still operates correctly as before.
Edited by Calin Culianu