X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Fbenchmarks%2Frun-length-prefix.c;h=d88e3afaa7e7a69d7bb30cd0853c6ff8aafd6a29;hb=5a510ed5696255910fd42adb47d7c1ffa728a116;hp=7d0336348e0028a922afe777b427f4ffa42628ed;hpb=8d97cddd18f504409ddb66dfe396798c99c2dfbd;p=ccan diff --git a/ccan/io/benchmarks/run-length-prefix.c b/ccan/io/benchmarks/run-length-prefix.c index 7d033634..d88e3afa 100644 --- a/ccan/io/benchmarks/run-length-prefix.c +++ b/ccan/io/benchmarks/run-length-prefix.c @@ -25,31 +25,30 @@ struct client { char *request_buffer; }; -static struct io_op *write_reply(struct io_conn *conn, struct client *client); -static struct io_op *read_body(struct io_conn *conn, struct client *client) +static struct io_plan write_reply(struct io_conn *conn, struct client *client); +static struct io_plan read_body(struct io_conn *conn, struct client *client) { assert(client->len <= REQUEST_MAX); return io_read(client->request_buffer, client->len, - io_next(conn, write_reply, client)); + write_reply, client); } -static struct io_op *read_header(struct io_conn *conn, struct client *client) +static struct io_plan io_read_header(struct client *client) { - return io_read(&client->len, sizeof(client->len), - io_next(conn, read_body, client)); + return io_read(&client->len, sizeof(client->len), read_body, client); } /* once we're done, loop again. */ -static struct io_op *write_complete(struct io_conn *conn, struct client *client) +static struct io_plan write_complete(struct io_conn *conn, struct client *client) { completed++; - return read_header(conn, client); + return io_read_header(client); } -static struct io_op *write_reply(struct io_conn *conn, struct client *client) +static struct io_plan write_reply(struct io_conn *conn, struct client *client) { return io_write(&client->len, sizeof(client->len), - io_next(conn, write_complete, client)); + write_complete, client); } /* This runs in the child. */ @@ -112,14 +111,9 @@ static void sigalarm(int sig) write(timeout[1], "1", 1); } -static struct io_op *do_timeout(struct io_conn *conn, char *buf) +static struct io_plan do_timeout(struct io_conn *conn, char *buf) { - return io_break(conn, NULL); -} - -static struct io_op *do_timeout_read(struct io_conn *conn, char *buf) -{ - return io_read(buf, 1, io_next(conn, do_timeout, buf)); + return io_break(buf, io_idle()); } int main(int argc, char *argv[]) @@ -163,11 +157,11 @@ int main(int argc, char *argv[]) err(1, "Accepting fd"); /* For efficiency, we share buffer */ client->request_buffer = buffer; - io_new_conn(ret, read_header, NULL, client); + io_new_conn(ret, io_read_header(client)); } } - io_new_conn(timeout[0], do_timeout_read, NULL, &buf); + io_new_conn(timeout[0], io_read(&buf, 1, do_timeout, &buf)); close(wake[0]); for (i = 0; i < NUM_CHILDREN; i++)