From d7c7d5df2965b905f9987c16fc86111b7a1a82a5 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Fri, 6 Oct 2006 23:16:58 +0000 Subject: [PATCH] Remove "wants_reads" field from struct io_fd. Everybody wants read information, so give it to them! src/ioset-epoll.c (ioset_epoll_events): Make EPOLLIN unconditional. src/ioset-impl.h (fd_wants_reads): Delete. src/ioset-select.c (ioset_select_loop): Unconditionally set read bit for fd. src/ioset.c (ioset_add): Add fd to engine after marking it non-blocking. (ioset_buffered_reads): Remove check for fd->wants_reads. src/ioset.h (struct io_fd): Delete "wants_reads" field. src/mod-qserver.c (qserver_readable): Add missing newline. (qserver_accept): Delete assignment to fd->wants_reads. src/mod-sockcheck.c (sockcheck_connected): Delete assignment to fd->wants_reads. src/proto-common.c (create_socket_client): Delete assignment to fd->wants_reads. git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-56 --- ChangeLog | 35 +++++++++++++++++++++++++++++++++++ src/ioset-epoll.c | 2 +- src/ioset-impl.h | 1 - src/ioset-select.c | 3 +-- src/ioset.c | 4 ++-- src/ioset.h | 1 - src/mod-qserver.c | 3 +-- src/mod-sockcheck.c | 1 - src/proto-common.c | 1 - 9 files changed, 40 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index c271b7f..102e794 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,41 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3 # +2006-10-06 23:16:58 GMT Michael Poole patch-56 + + Summary: + Remove "wants_reads" field from struct io_fd. + Revision: + srvx--devo--1.3--patch-56 + + Everybody wants read information, so give it to them! + + src/ioset-epoll.c (ioset_epoll_events): Make EPOLLIN unconditional. + + src/ioset-impl.h (fd_wants_reads): Delete. + + src/ioset-select.c (ioset_select_loop): Unconditionally set read bit for fd. + + src/ioset.c (ioset_add): Add fd to engine after marking it non-blocking. + (ioset_buffered_reads): Remove check for fd->wants_reads. + + src/ioset.h (struct io_fd): Delete "wants_reads" field. + + src/mod-qserver.c (qserver_readable): Add missing newline. + (qserver_accept): Delete assignment to fd->wants_reads. + + src/mod-sockcheck.c (sockcheck_connected): Delete assignment to + fd->wants_reads. + + src/proto-common.c (create_socket_client): Delete assignment to + fd->wants_reads. + + modified files: + ChangeLog src/ioset-epoll.c src/ioset-impl.h + src/ioset-select.c src/ioset.c src/ioset.h src/mod-qserver.c + src/mod-sockcheck.c src/proto-common.c + + 2006-10-06 23:12:20 GMT Michael Poole patch-55 Summary: diff --git a/src/ioset-epoll.c b/src/ioset-epoll.c index 4e0589c..a6b002e 100644 --- a/src/ioset-epoll.c +++ b/src/ioset-epoll.c @@ -46,7 +46,7 @@ static int ioset_epoll_events(struct io_fd *fd) { return EPOLLHUP - | (fd_wants_reads(fd) ? EPOLLIN : 0) + | EPOLLIN | (fd_wants_writes(fd) ? EPOLLOUT : 0) ; } diff --git a/src/ioset-impl.h b/src/ioset-impl.h index d6b3045..a3c12ce 100644 --- a/src/ioset-impl.h +++ b/src/ioset-impl.h @@ -25,7 +25,6 @@ struct timeval; -#define fd_wants_reads(FD) ((FD)->wants_reads || (FD)->state == IO_LISTENING) #define fd_wants_writes(FD) (((FD)->send.get != (FD)->send.put) || (FD)->state == IO_CONNECTING) struct io_engine { diff --git a/src/ioset-select.c b/src/ioset-select.c index d25738d..64afa0f 100644 --- a/src/ioset-select.c +++ b/src/ioset-select.c @@ -118,8 +118,7 @@ ioset_select_loop(struct timeval *timeout) if (!(fd = fds[nn])) continue; max_fd = nn; - if (fd_wants_reads(fd)) - FD_SET(nn, &read_fds); + FD_SET(nn, &read_fds); if (fd_wants_writes(fd)) FD_SET(nn, &write_fds); } diff --git a/src/ioset.c b/src/ioset.c index 7220413..6013232 100644 --- a/src/ioset.c +++ b/src/ioset.c @@ -142,9 +142,9 @@ ioset_add(int fd) { res->fd = fd; ioq_init(&res->send, 1024); ioq_init(&res->recv, 1024); - engine->add(res); flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, flags|O_NONBLOCK); + engine->add(res); return res; } @@ -406,7 +406,7 @@ ioset_buffered_read(struct io_fd *fd) { if (fd->recv.put == fd->recv.size) fd->recv.put = 0; fdnum = fd->fd; - while (fd->wants_reads && (fd->line_len > 0)) { + while (fd->line_len > 0) { struct io_fd *old_active; int died = 0; diff --git a/src/ioset.h b/src/ioset.h index 48e6924..36bb4ae 100644 --- a/src/ioset.h +++ b/src/ioset.h @@ -35,7 +35,6 @@ struct io_fd { int fd; void *data; enum { IO_CLOSED, IO_LISTENING, IO_CONNECTING, IO_CONNECTED } state; - unsigned int wants_reads : 1; unsigned int line_reads : 1; int line_len; struct ioq send; diff --git a/src/mod-qserver.c b/src/mod-qserver.c index 3eef51b..ea67282 100644 --- a/src/mod-qserver.c +++ b/src/mod-qserver.c @@ -89,7 +89,7 @@ qserver_readable(struct io_fd *fd) tmpline[--len] = '\0'; argc = split_line(tmpline, false, ArrayLength(argv), argv); if (argc < 3) { - ioset_printf(fd, "MISSING_ARGS"); + ioset_printf(fd, "MISSING_ARGS\n"); return; } if (!strcmp(argv[1], "PASS") @@ -134,7 +134,6 @@ qserver_accept(UNUSED_ARG(struct io_fd *listener), struct io_fd *fd) client = calloc(1, sizeof(*client)); fd->data = client; - fd->wants_reads = 1; fd->line_reads = 1; fd->readable_cb = qserver_readable; fd->destroy_cb = qserver_destroy_fd; diff --git a/src/mod-sockcheck.c b/src/mod-sockcheck.c index 8091c8a..a21aad9 100644 --- a/src/mod-sockcheck.c +++ b/src/mod-sockcheck.c @@ -644,7 +644,6 @@ sockcheck_connected(struct io_fd *fd, int rc) return; case 0: break; } - fd->wants_reads = 1; if (SOCKCHECK_DEBUG) { log_module(PC_LOG, LOG_INFO, "Connected: to %s port %d.", client->addr->hostname, client->state->port); } diff --git a/src/proto-common.c b/src/proto-common.c index 64a43d9..abb3a91 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -144,7 +144,6 @@ create_socket_client(struct uplinkNode *target) socket_io_fd->readable_cb = uplink_readable; socket_io_fd->destroy_cb = socket_destroyed; socket_io_fd->line_reads = 1; - socket_io_fd->wants_reads = 1; log_module(MAIN_LOG, LOG_INFO, "Connection to server established."); cManager.uplink = target; target->state = AUTHENTICATING; -- 2.20.1