]> git.ozlabs.org Git - ccan/commit
io: always make fds O_NONBLOCK.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 8 Aug 2014 05:10:47 +0000 (14:40 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 8 Aug 2014 05:33:27 +0000 (15:03 +0930)
commit897626152d12d7fd13a8feb36989eb5c8c1f3485
treed1a335afcb7b4a70697b6c10b534c9d052a06e12
parent8d94c52a7d6a51fd3a95734b2b4c7daa8c687d91
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>
ccan/io/io.c