]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/test/run-19-always.c
io: remove io_debug support.
[ccan] / ccan / io / test / run-19-always.c
index 1805f79f6619b310834f191b36161e33aba741b0..af190a4d025efeaa085ff9fd0c4711352a14f0f8 100644 (file)
@@ -6,9 +6,7 @@
 #include <sys/wait.h>
 #include <stdio.h>
 
-#ifndef PORT
 #define PORT "65019"
-#endif
 
 struct data {
        int state;
@@ -20,21 +18,22 @@ static void finish_ok(struct io_conn *conn, struct data *d)
 {
        ok1(d->state == 1);
        d->state++;
-       io_break(d, io_never());
+       io_break(d);
 }
 
-static struct io_plan write_buf(struct io_conn *conn, struct data *d)
+static struct io_plan *write_buf(struct io_conn *conn, struct data *d)
 {
-       return io_write(d->buf, d->bytes, io_close_cb, d);
+       return io_write(conn, d->buf, d->bytes, io_close_cb, d);
 }
 
-static void init_conn(int fd, struct data *d)
+static struct io_plan *init_conn(struct io_conn *conn, struct data *d)
 {
        ok1(d->state == 0);
        d->state++;
+       io_set_finish(conn, finish_ok, d);
+
        /* Empty read should run immediately... */
-       io_set_finish(io_new_conn(fd, io_read(NULL, 0, write_buf, d)),
-                     finish_ok, d);
+       return io_read(conn, NULL, 0, write_buf, d);
 }
 
 static int make_listen_fd(const char *port, struct addrinfo **info)
@@ -105,7 +104,7 @@ int main(void)
        memset(d->buf, 'a', d->bytes);
        fd = make_listen_fd(PORT, &addrinfo);
        ok1(fd >= 0);
-       l = io_new_listener(fd, init_conn, d);
+       l = io_new_listener(NULL, fd, init_conn, d);
        ok1(l);
        fflush(stdout);
        if (!fork()) {
@@ -116,7 +115,7 @@ int main(void)
                free(d);
                exit(0);
        }
-       ok1(io_loop() == d);
+       ok1(io_loop(NULL, NULL) == d);
        ok1(d->state == 2);
 
        ok1(wait(&status));