X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Ftest%2Frun-15-timeout.c;h=5709ddaa8a25416d6bb56c2a7d21ce81688e0e52;hp=e0a3b05ebdf4ca19b61ccd3982f58ff9c8e40489;hb=36bfb66bdf74f4f3382cd00dae7b899e80e2cf1a;hpb=94dd4c2bddd0dc080ad5b85465fa3f45f486967a diff --git a/ccan/io/test/run-15-timeout.c b/ccan/io/test/run-15-timeout.c index e0a3b05e..5709ddaa 100644 --- a/ccan/io/test/run-15-timeout.c +++ b/ccan/io/test/run-15-timeout.c @@ -8,7 +8,9 @@ #include #include -#ifndef PORT +#ifdef DEBUG_CONN +#define PORT "64015" +#else #define PORT "65015" #endif @@ -36,6 +38,9 @@ static struct io_plan *no_timeout(struct io_conn *conn, struct data *d) static struct io_plan *init_conn(struct io_conn *conn, struct data *d) { +#ifdef DEBUG_CONN + io_set_debug(conn, true); +#endif ok1(d->state == 0); d->state++; @@ -85,7 +90,7 @@ int main(void) struct data *d = malloc(sizeof(*d)); struct addrinfo *addrinfo; struct io_listener *l; - struct list_head expired; + struct timer *expired; int fd, status; /* This is how many tests you plan to run */ @@ -93,6 +98,7 @@ int main(void) d->state = 0; d->timeout_usec = 100000; timers_init(&d->timers, time_now()); + timer_init(&d->timer); fd = make_listen_fd(PORT, &addrinfo); ok1(fd >= 0); l = io_new_listener(NULL, fd, init_conn, d); @@ -124,15 +130,15 @@ int main(void) ok1(io_loop(&d->timers, &expired) == NULL); /* One element, d->timer. */ - ok1(list_pop(&expired, struct timer, list) == &d->timer); - ok1(list_empty(&expired)); + ok1(expired == &d->timer); + ok1(!timers_expire(&d->timers, time_now())); ok1(d->state == 1); io_close(d->conn); /* Finished will be called, d will be returned */ ok1(io_loop(&d->timers, &expired) == d); - ok1(list_empty(&expired)); + ok1(expired == NULL); ok1(d->state == 2); /* It should have died. */ @@ -169,7 +175,7 @@ int main(void) } ok1(io_loop(&d->timers, &expired) == d); ok1(d->state == 3); - ok1(list_empty(&expired)); + ok1(expired == NULL); ok1(wait(&status)); ok1(WIFEXITED(status)); ok1(WEXITSTATUS(status) >= sizeof(d->buf));