char buf[4];
};
-static struct io_op *do_read(struct io_conn *conn, struct data *d)
+static struct io_plan plan_read(struct io_conn *conn, struct data *d)
{
ok1(d->state == 2 || d->state == 3);
d->state++;
- return io_read(d->buf, sizeof(d->buf), io_next(conn, io_close, d));
+ return io_read(d->buf, sizeof(d->buf), io_close, d);
}
-static struct io_op *start_waker(struct io_conn *conn, struct data *d)
+static struct io_plan start_waker(struct io_conn *conn, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_wake(idler, do_read, d);
+ io_wake(idler, plan_read, d);
return io_close(conn, NULL);
}
d->state++;
}
-static struct io_op *start_idle(struct io_conn *conn, struct data *d)
+static struct io_plan start_idle(struct io_conn *conn, struct data *d)
{
int fd;
ok1(fd >= 0);
ok1(io_new_conn(fd, start_waker, finish_waker, d));
- return io_idle(conn);
+ return io_idle();
}
static void finish_idle(struct io_conn *conn, struct data *d)
{
ok1(d->state == 4);
d->state++;
- io_break(d, NULL);
+ io_break(d, NULL, NULL);
+}
+
+static void init_conn(int fd, struct data *d)
+{
+ if (!io_new_conn(fd, start_idle, finish_idle, d))
+ abort();
}
static int make_listen_fd(const char *port, struct addrinfo **info)
d->state = 0;
fd = make_listen_fd("65006", &addrinfo);
ok1(fd >= 0);
- l = io_new_listener(fd, start_idle, finish_idle, d);
+ l = io_new_listener(fd, init_conn, d);
ok1(l);
fflush(stdout);
if (!fork()) {