]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/test/run-17-homemade-io.c
ccan/io: implement debug.
[ccan] / ccan / io / test / run-17-homemade-io.c
index a868b2132783401941e54bdf3734b9e3c923bd60..325a7468eb4ac4b08b1ac7fc2b7abc1a565942f0 100644 (file)
@@ -6,7 +6,9 @@
 #include <sys/wait.h>
 #include <stdio.h>
 
-#ifndef PORT
+#ifdef DEBUG_CONN
+#define PORT "64017"
+#else
 #define PORT "65017"
 #endif
 
@@ -77,15 +79,15 @@ static struct io_plan *io_read_packet(struct io_conn *conn,
        pkt->contents = NULL;
        plan->u1.vp = pkt;
        plan->u2.s = 0;
-       plan->io = do_read_packet;
-       plan->next = cb;
-       plan->next_arg = arg;
 
-       return plan;
+       return io_set_plan(conn, plan, do_read_packet, cb, arg);
 }
 
 static struct io_plan *init_conn(struct io_conn *conn, struct packet *pkt)
 {
+#ifdef DEBUG_CONN
+       io_set_debug(conn, true);
+#endif
        ok1(pkt->state == 0);
        pkt->state++;
 
@@ -166,7 +168,7 @@ int main(void)
                exit(0);
        }
        freeaddrinfo(addrinfo);
-       ok1(io_loop() == pkt);
+       ok1(io_loop(NULL, NULL) == pkt);
        ok1(pkt->state == 4);
        ok1(pkt->len == 8);
        ok1(memcmp(pkt->contents, "hithere!", 8) == 0);