Age | Commit message (Collapse) | Author |
|
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
Helper for a common case. Replace all but 1 in tests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
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>
|
|
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>
|
|
This is actually pretty simple now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
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>
|
|
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
And add test for that which also tests duplex case.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
This reverts commit 490b63852f281f0d72eb6f6dfa5e0dce36bcbe0d.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Conflicts:
ccan/io/io.c
|
|
Turns out to be useful for complex cases.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
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>
|
|
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>
|
|
Useful for getsockname().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
I really wanted an array of bytes in there, so make it more flexible.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
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>
|
|
Don't call from the plan-construction function, call after it returns.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Overloading io_close() as a callback is ugly: create an explicit
io_close_cb().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
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>
|
|
And rename debug_io_plan() to io_plan_debug() so it can be exposed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
In particular, make sure that idle connections don't get closed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Use a NULL next pointer instead to indicate a closing connection.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
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>
|
|
No longer needed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
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>
|
|
Explicit callbacks are slower, but more flexible.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
This is a better description, since it's I/O we plan to do next.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Upgrade license, since timer is LGPL.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
It's probably a bug if we're waiting for nothing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Cleaner model for I/O, with cost of complexity if you really want bidir.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
|
Designed for async I/O.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|