X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fio%2Fbenchmarks%2Frun-different-speed.c;h=5ee15ea6d0235ce929b0e171db24e4c8eb977a1e;hb=641b511049e5c03d45ada0c3fd829691b173e5d1;hp=cbc9ad6a9f81c6cc531afe7d258a91d4163ef544;hpb=7a8a585c32d1010426f587a6933f05de7a06dfd0;p=ccan diff --git a/ccan/io/benchmarks/run-different-speed.c b/ccan/io/benchmarks/run-different-speed.c index cbc9ad6a..5ee15ea6 100644 --- a/ccan/io/benchmarks/run-different-speed.c +++ b/ccan/io/benchmarks/run-different-speed.c @@ -25,24 +25,24 @@ struct client { char reply_buffer[REPLY_SIZE]; }; -static struct io_plan *write_reply(struct io_conn *conn, struct client *client); -static struct io_plan *read_request(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_request(struct io_conn *conn, struct client *client) { return io_read(client->request_buffer, REQUEST_SIZE, - io_next(conn, write_reply, client)); + write_reply, client); } /* once we're done, loop again. */ -static struct io_plan *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_request(conn, client); } -static struct io_plan *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->reply_buffer, REPLY_SIZE, - io_next(conn, write_complete, client)); + write_complete, client); } /* This runs in the child. */ @@ -106,14 +106,9 @@ static void sigalarm(int sig) write(timeout[1], "1", 1); } -static struct io_plan *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_plan *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[]) @@ -155,11 +150,13 @@ int main(int argc, char *argv[]) if (ret < 0) err(1, "Accepting fd"); /* For efficiency, we share client structure */ - io_new_conn(ret, read_request, NULL, &client); + io_new_conn(ret, + io_read(client.request_buffer, REQUEST_SIZE, + write_reply, &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++)