io: always make fds O_NONBLOCK.
Debugging an issue where pettycoin would become unresponsive, I discovered
this:
poll([{fd=5, events=POLLIN}, {fd=19, events=POLLIN}, {fd=6, events=POLLIN}, {fd=15, events=POLLIN}, {fd=8, events=POLLIN}, {fd=-11}, {fd=7, events=POLL
OUT}], 7, -1) = 1 ([{fd=7, revents=POLLOUT}]) <0.000014>
write(7, "\224]\4\0\4\0\0\0\200\203\16\234\v\262\276\321h\357\217Y\0\204\21\31\253\304#U\0206}\20"..., 286100) = 159280 <98.894019>
Despite poll saying the (TCP socket) fd was ready, the write took 98 seconds!
The results were far more reasonable with O_NONBLOCK:
write(9, "%\247l0\337^\216\24\323\2705\203Y\340h\2767/bM\373?dM\254\22g\310\v\0\0\0"..., 206460) = 40544 <0.000052>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Showing
Please register or sign in to comment