]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/test/run-14-duplex-both-read.c
io: handle errors on listening file descriptors.
[ccan] / ccan / io / test / run-14-duplex-both-read.c
index b52553aaf5be7235015d51c38b51e07a54241d54..ed77cab8ac69d4530f0525c24f6c1db22407fb17 100644 (file)
@@ -8,9 +8,7 @@
 #include <sys/wait.h>
 #include <stdio.h>
 
-#ifndef PORT
 #define PORT "65014"
-#endif
 
 struct data {
        struct io_listener *l;
@@ -27,17 +25,19 @@ static void finish_ok(struct io_conn *conn, struct data *d)
 static struct io_plan *end(struct io_conn *conn, struct data *d)
 {
        d->state++;
+       /* Close on top of halfclose should work. */
        if (d->state == 4)
                return io_close(conn);
        else
-               return io_wait(conn, NULL, io_never, NULL);
+               return io_halfclose(conn);
 }
 
 static struct io_plan *make_duplex(struct io_conn *conn, struct data *d)
 {
        d->state++;
        /* Have duplex read the rest of the buffer. */
-       return io_duplex(io_read(conn, d->buf+1, sizeof(d->buf)-1, end, d),
+       return io_duplex(conn,
+                        io_read(conn, d->buf+1, sizeof(d->buf)-1, end, d),
                         io_write(conn, d->wbuf, sizeof(d->wbuf), end, d));
 }
 
@@ -125,7 +125,7 @@ int main(void)
                exit(0);
        }
        freeaddrinfo(addrinfo);
-       ok1(io_loop() == NULL);
+       ok1(io_loop(NULL, NULL) == NULL);
        ok1(d->state == 5);
        ok1(memcmp(d->buf, "hellothere", sizeof(d->buf)) == 0);
        free(d);