ccan/io: add debugging helper for seeing if module is in charge of an fd. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: fix typo in example. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: add new io_sock_shutdown helper. Turns out that there's no good way to flush a socket: https://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: typo fixes. Suggested-by: Lisa Neigut <@niftynei> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/io: add io_conn_exclusive and io_conn_out_exclusive. There are cases where we want to suppress all activity except for a single fd; we already have ugly io_flush_sync, but this is more useful and more general. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: don't leave errno as a random value when we hit EOF. It's used inside io_finish; setting to 0 allows that to know we hit EOF on a read. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: query whether io_plan in/out have started. For lightning, we want to hand the socket off to another daemon, but we need to be on a packet boundary. This lets us check if we've part-read or part-written. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: add io_fd_block() helper. It's a common thing to want to do, so add helper here. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: allow overriding poll function. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: add io_flush_sync(). This is needed for emergency handling in lightningd: we want to output a (fatal) error packet on the socket, but we don't want to do so in the middle of another packet. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: make io_close_taken_fd() unset nonblocking on the fd. This is what users want, and expect: as demonstrated by the test failure when not under valgrind! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: handle errors on listening file descriptors. While investigating the previous patch, a bug caused poll to return POLLHUP on the listening socket, which caused us to spin. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: io_close_taken_fd to steal fd from conn. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: update documentation for io_close. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: remove io_debug support. It seemed like a good idea, but it complicates things and I never used it (since I never really trusted that the alternate paths would be equivalent). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: update to use time_mono() for timers. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: fix maybe-uninitialized warning in test (-O2) /home/rusty/devel/cvs/ccan/ccan/io/test/run-01-start-finish.c: In function ‘main’: /home/rusty/devel/cvs/ccan/ccan/io/test/run-01-start-finish.c:89:7: warning: ‘addrinfo’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (connect(fd, addrinfo->ai_addr, addrinfo->ai_addrlen) != 0) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: io_time_override to insert fake times. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
io: update for new timer API. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/io: add io_out_wait() and io_out_always(). This specificity is required, for example, when doing: return io_duplex(conn, io_read(...), io_always(...)); The workaround suggested doesn't work, because io_duplex_prepare() asserts() if the plans aren't UNSET to start. And pettycoin needs this. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>