X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-17-homemade-io.c;h=00fbf2233c59c9132c3f1c74a40e630429a64bf5;hp=08c081ec4238a1870637c39eb964b241d822c8c8;hb=9e02685a6216720d37848a332187e3745b7f981e;hpb=e2ce04eac30ec613c858bd4cd2ca12e1c464edb8 diff --git a/ccan/io/test/run-17-homemade-io.c b/ccan/io/test/run-17-homemade-io.c index 08c081ec..00fbf223 100644 --- a/ccan/io/test/run-17-homemade-io.c +++ b/ccan/io/test/run-17-homemade-io.c @@ -23,7 +23,7 @@ static void finish_ok(struct io_conn *conn, struct packet *pkt) io_break(pkt, io_idle()); } -static bool do_read_packet(int fd, struct io_plan *plan) +static int do_read_packet(int fd, struct io_plan *plan) { struct packet *pkt = plan->u.ptr_len.p; char *dest; @@ -41,7 +41,7 @@ static bool do_read_packet(int fd, struct io_plan *plan) ok1(pkt->state == 2); pkt->state++; if (pkt->len == 0) - return true; + return 1; if (!pkt->contents && !(pkt->contents = malloc(pkt->len))) goto fail; else { @@ -63,9 +63,7 @@ static bool do_read_packet(int fd, struct io_plan *plan) fail: free(pkt->contents); - /* Override next function to close us. */ - plan->next = io_close; - return true; + return -1; } static struct io_plan io_read_packet(struct packet *pkt, @@ -83,7 +81,6 @@ static struct io_plan io_read_packet(struct packet *pkt, plan.next_arg = arg; plan.pollflag = POLLIN; - io_plan_debug(&plan); return plan; } @@ -92,8 +89,8 @@ static void init_conn(int fd, struct packet *pkt) ok1(pkt->state == 0); pkt->state++; - if (!io_new_conn(fd, io_read_packet(pkt, io_close, pkt), finish_ok, pkt)) - abort(); + io_set_finish(io_new_conn(fd, io_read_packet(pkt, io_close_cb, pkt)), + finish_ok, pkt); } static int make_listen_fd(const char *port, struct addrinfo **info)