summaryrefslogtreecommitdiff
path: root/ccan/io/test
AgeCommit message (Collapse)Author
2014-10-31io: update for new timer API.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-08-04ccan/io: add io_out_wait() and io_out_always().Rusty Russell
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>
2014-08-04ccan/io: io_halfclose.Rusty Russell
Helper for a common case. Replace all but 1 in tests. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-08-04ccan/io: keep more io_plan details internal.Rusty Russell
To write a normal helper you only need access to the args, so only expose that. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-08-04ccan/io: implement debug.Rusty Russell
Now a simple flag, with an external toggle (no compile time DEBUG define required). But it's completely synchronous. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-08-04ccan/io: implement timeouts.Rusty Russell
We do this by the simplest method: return from io_loop() and let the caller sort them out. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-08-04ccan/io: duplex support.Rusty Russell
This is actually pretty simple now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-08-04ccan/io: eliminate dir argument from io_wait and io_always.Rusty Russell
We can use either empty slot for this, so figure it out internally. This could cause problems if you want to use it with io_duplex, so document that. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-08-03ccan/io: rewrite.Rusty Russell
I found it difficult to use myself, particularly io_duplex(). So this removes that, as well as timers and debug (for the moment). API changes: 1) An io_plan is passed by pointer, rather than copied on the stack. 3) All io_plans are generated using the struct io_conn. 3) tal is the allocator. 4) A new connection must be set up with a callback, so this is now the same as one generated from a listener. 5) io_read_partial and io_write_partial take an explicit length. 6) io_always() and io_wait() take an explit in/out arg. 7) io_break() does not return a plan. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-04-24io: change io_idle() to io_wait()Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-04-24io: io_never for events that should never happen.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-12-07io: io_always, and zero-length operations support.Rusty Russell
A zero-length read should complete immediately, even if the fd isn't readable. Wire this up, and expose it for callers to use. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-12-01io: io_close_other()Rusty Russell
And add test for that which also tests duplex case. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-12-01Revert "io: closing one side of a duplex connection closes both."Rusty Russell
This reverts commit 490b63852f281f0d72eb6f6dfa5e0dce36bcbe0d. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Conflicts: ccan/io/io.c
2013-11-14io: add io_is_idle().Rusty Russell
Turns out to be useful for complex cases. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-11-14io: handle duplex corner cases.Rusty Russell
Especially where we have just done a read and spin off a duplex to do a read as well. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-11-12io: closing one side of a duplex connection closes both.Rusty Russell
Otherwise, it's a PITA to close a duplexed connection. If necessary we can introduce a half-close to de-deplex later. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-29io: fix port clash in test.Rusty Russell
Both run-set_alloc and run-15-timeout used the same port, so they sometimes got stuck when running in parallel. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-21io: add io_conn_fd()Rusty Russell
Useful for getsockname(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-21io: io_set_alloc()Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-16ccan/io: make union more generic.Rusty Russell
I really wanted an array of bytes in there, so make it more flexible. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: io_connect()Rusty Russell
Not a perfect solution (we'd ideally want to go to another plan immediately, but that would involve a malloc). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: flatten debug callchain further.Rusty Russell
Don't call through io_loop, but have it pass the connection back and call manually. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: flatten debug callchain.Rusty Russell
Don't call from the plan-construction function, call after it returns. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: save errno on io_close, for finish functions.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: io_close_cb()Rusty Russell
Overloading io_close() as a callback is ugly: create an explicit io_close_cb(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: simplify I/O callbacks.Rusty Russell
Use a -1 for error codes. This makes it easier to write your own io funcs. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: io_set_finish()Rusty Russell
Rather than insisting on supplying them on every call to io_new_conn(). Also, this way it can be changed on a connection. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: test custom io functions.Rusty Russell
And rename debug_io_plan() to io_plan_debug() so it can be exposed. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: go linear for debugging.Rusty Russell
Debugging an async library is a pain: it's nice to force it into a linear call chain to try to track problems. Ugly code, though. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: test read after hangup.Rusty Russell
In particular, make sure that idle connections don't get closed. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: remove io_state.Rusty Russell
Use a NULL next pointer instead to indicate a closing connection. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: initialize connection with an explicit I/O plan.Rusty Russell
Rather than going via a callback, which tends to just set up I/O, do any setup before the call to io_new_conn(), then pass it the io_plan directly. The patch shows how much this simplifies our test code. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: generic init function for listening connections.Rusty Russell
Instead of assuming they want a connection made from the new fd, hand the fd to a callback. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: remove conn arg from io_plan constructors.Rusty Russell
No longer needed. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: pass struct io_plan explicitly.Rusty Russell
This simplifies some things: in particular, we can construct an io_plan without needing the current io_conn. On the other hand, we need to expose the structure now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: use explicit IO callback functions, instead of io_state values.Rusty Russell
Explicit callbacks are slower, but more flexible. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: get rid of io_next(), pass callbacks directly.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: rename io_op to io_plan.Rusty Russell
This is a better description, since it's I/O we plan to do next. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: timer support.Rusty Russell
Upgrade license, since timer is LGPL. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: check for all idle.Rusty Russell
It's probably a bug if we're waiting for nothing. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: io_duplex.Rusty Russell
Cleaner model for I/O, with cost of complexity if you really want bidir. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2013-10-14ccan/io: new module.Rusty Russell
Designed for async I/O. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>