X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fbenchmarks%2Frun-different-speed.c;h=c540f48d3a12744317a6316a8acbc6e7c76a1f5f;hp=537a67bbc01b5de934f63db04612e27d276f9415;hb=3ffb94e9aad84dc0d8e19a5a7d709589d7956ddf;hpb=625bae8f5720d3ad3253ea9b26ad68abcd81bde5 diff --git a/ccan/io/benchmarks/run-different-speed.c b/ccan/io/benchmarks/run-different-speed.c index 537a67bb..c540f48d 100644 --- a/ccan/io/benchmarks/run-different-speed.c +++ b/ccan/io/benchmarks/run-different-speed.c @@ -28,7 +28,7 @@ struct 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(conn, client->request_buffer, REQUEST_SIZE, + return io_read(client->request_buffer, REQUEST_SIZE, write_reply, client); } @@ -41,7 +41,7 @@ static struct io_plan write_complete(struct io_conn *conn, struct client *client static struct io_plan write_reply(struct io_conn *conn, struct client *client) { - return io_write(conn, client->reply_buffer, REPLY_SIZE, + return io_write(client->reply_buffer, REPLY_SIZE, write_complete, client); } @@ -60,7 +60,7 @@ static void create_clients(struct sockaddr_un *addr, int waitfd) if (connect(sock[i], (void *)addr, sizeof(*addr)) != 0) err(1, "connecting socket"); /* Make nonblocking. */ - fcntl(sock[i], F_SETFD, fcntl(sock[i], F_GETFD)|O_NONBLOCK); + io_fd_block(sock[i], false); done[i] = 0; } @@ -108,12 +108,7 @@ static void sigalarm(int sig) static struct io_plan do_timeout(struct io_conn *conn, char *buf) { - return io_break(conn, buf, NULL, NULL); -} - -static struct io_plan do_timeout_read(struct io_conn *conn, char *buf) -{ - return io_read(conn, buf, 1, 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++)