Commit b57bf034 authored by Rusty Russell's avatar Rusty Russell

ccan/io: example failure

So many bugs in one example program!

There was an unrelated but which strace revealed (trying to write -7
bytes), but I think your issue was more prosaic: failing to zero the
from buffer.
Reported-by: default avatarIan Zimmerman <itz@very.loosely.org>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 759ac0f0
......@@ -61,9 +61,10 @@
* {
* // Remove what we just wrote.
* b->start += b->wlen;
* b->wlen = 0;
* assert(b->start <= sizeof(b->buf));
*
* // If we wrote something, wake writer.
* // If we wrote something, wake reader.
* if (b->wlen != 0)
* io_wake(b);
*
......@@ -114,6 +115,7 @@
* io_new_conn(NULL, tochild[1], write_out, &to);
*
* // Read from child, write to stdout.
* memset(&from, 0, sizeof(from));
* reader = io_new_conn(NULL, fromchild[0], read_in, &from);
* io_set_finish(reader, finish, &from);
* io_new_conn(NULL, STDOUT_FILENO, write_out, &from);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment