Re: [PATCH] libbb: rename two fields in ioloop_state, no logic changes
Guillermo Rodriguez Garcia via busybox <[email protected]> Tue, 21 Apr 2026 12:21:07 +0200
| Newsgroups | gmane.linux.busybox |
|---|---|
| Message-ID | <CABDcavY5Ao3tHOLumVwe+T50fJh=_eYe=yummQXLaQuGNzsuAQ@mail.gmail.com> |
Hi Victor, This patch is already included in git. I assume you did not mean to send it ? Guillermo El mar, 21 abr 2026 a las 9:34, Victor Erminpour via busybox (<[email protected]>) escribió: > > From: Denys Vlasenko <[email protected]> > > Signed-off-by: Denys Vlasenko <[email protected]> > --- > include/libbb.h | 4 ++-- > libbb/ioloop.c | 30 +++++++++++++++--------------- > networking/telnet.c | 16 ++++++++-------- > networking/telnetd.c | 38 +++++++++++++++++++------------------- > 4 files changed, 44 insertions(+), 44 deletions(-) > > diff --git a/include/libbb.h b/include/libbb.h > index 0fee62929..a54f17d49 100644 > --- a/include/libbb.h > +++ b/include/libbb.h > @@ -728,8 +728,8 @@ typedef struct ioloop_state { > ioloop_state_t *io; \ > int read_fd; \ > int write_fd; \ > - int (*have_buffer_to_read_into)(void *this); \ > - int (*have_data_to_write)(void *this); \ > + int (*should_poll_read_fd)(void *this); \ > + int (*should_poll_write_fd)(void *this); \ > int (*read)(void *this); \ > int (*write)(void *this); \ > > diff --git a/libbb/ioloop.c b/libbb/ioloop.c > index cc9876487..fbd780cf8 100644 > --- a/libbb/ioloop.c > +++ b/libbb/ioloop.c > @@ -76,19 +76,19 @@ void FAST_FUNC ioloop_close_fd_in_all_conns(ioloop_state_t *io, int fd) > } > #endif > > -// have_data_to_write() - Do we have data to write? > +// should_poll_write_fd() - Should ioloop poll write_fd for writability? > // May return error if knows that write side is closed, even if it has free buffer space. > -// > 0: Has data to write (or can generate such data) > +// > 0: Yes, poll write_fd (has data to write, or can generate such data) > // In this case, write_fd must be valid! (it's a bug if it is < 0, can crash) > -// 0: No data to write currently > +// 0: No, don't poll write_fd currently > // < 0: error, I probably freed myself (do not use my structure in this iteration, > // on next iteration, if I indeed freed myself, you won't find me in the list). > // > -// have_buffer_to_read_into() - Is there a buffer to read into? > +// should_poll_read_fd() - Should ioloop poll read_fd for readability? > // May return error if knows that write side is closed, even if it has free buffer space. > -// > 0: Healthy, has buffer space, please poll read_fd > +// > 0: Yes, poll read_fd (has buffer space, healthy) > // In this case, read_fd must be valid! (it's a bug if it is < 0) > -// 0: One of: > +// 0: No, don't poll read_fd. One of: > // Buffer is full (hopefully write() will free some) > // Got error/EOF, want to drain write buffer first > // < 0: Error/EOF, I probably freed myself (do not use my structure) > @@ -121,26 +121,26 @@ void FAST_FUNC ioloop_close_fd_in_all_conns(ioloop_state_t *io, int fd) > // Putting "this connection is dead, close+remove+free" code into read function > // is often inconvenient: if you got EOF/error on read, you still want to poll write side > // and try to write out the buffered data to it. Which means read() can't "remove+free". > -// Instead, you can remember EOF/error and make future have_buffer_to_read_into() respond 0. > +// Instead, you can remember EOF/error and make future should_poll_read_fd() respond 0. > // One way is to close (if possible) read_fd, set it to -1 and use as a flag. > // > // If need to support one-sided close, such as when HTTP/1.x client sends us > // "GET / HTTP/1.1\r\n\r\n" and closes its writing side with shutdown(SHUT_WR), > // the idiom is that when read() sees EOF, it sets conn->read_fd to -1 > -// and subsequently have_buffer_to_read_into() always return 0 (no more attempts to read); > +// and subsequently should_poll_read_fd() always return 0 (no more attempts to read); > // write() flushes all remaining data to conn->write_fd and then signals EOF > // to write_fd: shutdown(SHUT_WR) for sockets, close() for pipes > // (how to do this for ptys!?). > -// After this, have_data_to_write() can return 0 if fd has to stay open (socket) > +// After this, should_poll_write_fd() can return 0 if fd has to stay open (socket) > // or can return -1 and free itself if fd is closed. > > -static ALWAYS_INLINE int have_data_to_write(connection_t *conn) > +static ALWAYS_INLINE int should_poll_write_fd(connection_t *conn) > { > - return conn->have_data_to_write(conn); > + return conn->should_poll_write_fd(conn); > } > -static ALWAYS_INLINE int have_buffer_to_read_into(connection_t *conn) > +static ALWAYS_INLINE int should_poll_read_fd(connection_t *conn) > { > - return conn->have_buffer_to_read_into(conn); > + return conn->should_poll_read_fd(conn); > } > static ALWAYS_INLINE int write_from_buf(connection_t *conn) > { > @@ -177,7 +177,7 @@ int FAST_FUNC ioloop_run(ioloop_state_t *io) > int rcw, rcr; > > next = conn->next; /* in case conn is freed */ > - rcw = have_data_to_write(conn); > + rcw = should_poll_write_fd(conn); > if (rcw < 0) { > /* often indicates that conn is gone (freed), do not use it anymore */ > goto next; > @@ -186,7 +186,7 @@ int FAST_FUNC ioloop_run(ioloop_state_t *io) > * the *reader* may decide to abort (return rcr < 0)! > * Check it first: > */ > - rcr = have_buffer_to_read_into(conn); > + rcr = should_poll_read_fd(conn); > if (rcr < 0) > goto next; > if (rcw > 0) { > diff --git a/networking/telnet.c b/networking/telnet.c > index a0eadc91b..227a37907 100644 > --- a/networking/telnet.c > +++ b/networking/telnet.c > @@ -576,7 +576,7 @@ static void show_menu(void) > cookmode(); > } > > -static int have_buffer_to_read_from_stdin(void *this) > +static int should_poll_read_fd_stdin(void *this) > { > stdin_to_net_t *conn = this; > if (conn->read_fd < 0) > @@ -656,7 +656,7 @@ static int read_from_stdin(void *this) > return count; > } > > -static int have_data_to_write_to_net(void *this) > +static int should_poll_write_fd_net(void *this) > { > stdin_to_net_t *conn = this; > if (conn->size == 0 && conn->read_fd < 0) { > @@ -700,7 +700,7 @@ static int write_to_net(void *this) > return count; > } > > -static int have_buffer_to_read_from_net(void *this) > +static int should_poll_read_fd_net(void *this) > { > net_to_stdout_t *conn = this; > if (conn->read_fd < 0) > @@ -897,7 +897,7 @@ static int read_from_net(void *this) > return count; > } > > -static int have_data_to_write_to_stdout(void *this) > +static int should_poll_write_fd_stdout(void *this) > { > net_to_stdout_t *conn = this; > if (conn->size == 0 && conn->read_fd < 0) { > @@ -988,16 +988,16 @@ int telnet_main(int argc UNUSED_PARAM, char **argv) > signal(SIGPIPE, SIG_IGN); > > // Initialize connections > - G.conn_stdin2net.have_buffer_to_read_into = have_buffer_to_read_from_stdin; > - G.conn_stdin2net.have_data_to_write = have_data_to_write_to_net; > + G.conn_stdin2net.should_poll_read_fd = should_poll_read_fd_stdin; > + G.conn_stdin2net.should_poll_write_fd = should_poll_write_fd_net; > G.conn_stdin2net.read = read_from_stdin; > G.conn_stdin2net.write = write_to_net; > if (STDIN_FILENO != 0) > G.conn_stdin2net.read_fd = STDIN_FILENO; > G.conn_stdin2net.write_fd = netfd; > > - G.conn_net2stdout.have_buffer_to_read_into = have_buffer_to_read_from_net; > - G.conn_net2stdout.have_data_to_write = have_data_to_write_to_stdout; > + G.conn_net2stdout.should_poll_read_fd = should_poll_read_fd_net; > + G.conn_net2stdout.should_poll_write_fd = should_poll_write_fd_stdout; > G.conn_net2stdout.read = read_from_net; > G.conn_net2stdout.write = write_to_stdout; > G.conn_net2stdout.read_fd = netfd; > diff --git a/networking/telnetd.c b/networking/telnetd.c > index 3eb9446a2..880d3c63b 100644 > --- a/networking/telnetd.c > +++ b/networking/telnetd.c > @@ -279,8 +279,8 @@ static void ALWAYS_INLINE remove_and_free_to_net(pty_to_net_t *ts) > // Theory of operation > // (AKA "when should I close fds? when should I detach from ioloop?"). > // The fds are named read_fd and write_fd, but for clarity let's call them netfd and ptyfd. > -// net_to_pty::have_data_to_write > -// net_to_pty::have_buffer_to_read_into > +// net_to_pty::should_poll_write_fd > +// net_to_pty::should_poll_read_fd > // if ptyfd < 0: //sibling told us ptyfd is down? > // if sibling && sibling->netfd >= 0: netfd = -1; //do not close netfd, sibling uses it (if sibling exists)! > // close_and_detach; > @@ -308,7 +308,7 @@ static unsigned char read_byte_unescaping_IAC(int *iac_cnt, unsigned char **pp) > return c; > } > > -static int net_to_pty__have_data_to_write(void *this) > +static int net_to_pty__should_poll_write_fd(void *this) > { > //connection_t *conn = this; > net_to_pty_t *ts = this; > @@ -471,7 +471,7 @@ static int net_to_pty__write(void *this) > found = memchr(buf, IAC, wr); > if (found == buf) { > /* The first char is IAC. > - * have_data_to_write() ensures we are only called this way > + * should_poll_write_fd() ensures we are only called this way > * if there are two IACs. > * It also ensures the buffer is not wrapping within 7 chars. > * Write one IAC. If that works, skip both. > @@ -524,7 +524,7 @@ static int net_to_pty__write(void *this) > } > > /* Check if buffer has space to read into */ > -static int net_to_pty__have_buffer_to_read_into(void *this) > +static int net_to_pty__should_poll_read_fd(void *this) > { > //connection_t *conn = this; > net_to_pty_t *ts = this; > @@ -619,17 +619,17 @@ static int net_to_pty__read(void *this) > static net_to_pty_t *new_net_to_pty(int from, int to) > { > net_to_pty_t *this = xzalloc(sizeof(*this) + TO_PTY_BUFSIZE); > - this->have_buffer_to_read_into = net_to_pty__have_buffer_to_read_into; > - this->have_data_to_write = net_to_pty__have_data_to_write; > - this->read = net_to_pty__read; > - this->write = net_to_pty__write; > + this->should_poll_read_fd = net_to_pty__should_poll_read_fd; > + this->should_poll_write_fd = net_to_pty__should_poll_write_fd; > + this->read = net_to_pty__read; > + this->write = net_to_pty__write; > this->read_fd = from; > this->write_fd = to; > /* indexes and size are all 0 */ > return this; > } > > -static int pty_to_net__have_buffer_to_read_into(void *this) > +static int pty_to_net__should_poll_read_fd(void *this) > { > //connection_t *conn = this; > pty_to_net_t *ts = this; > @@ -725,7 +725,7 @@ static int pty_to_net__read(void *this) > return count; > } > > -static int pty_to_net__have_data_to_write(void *this) > +static int pty_to_net__should_poll_write_fd(void *this) > { > pty_to_net_t *ts = this; > if (ts->size == 0) { > @@ -832,10 +832,10 @@ static int pty_to_net__write(void *this) > static pty_to_net_t *new_pty_to_net(int from, int to) > { > pty_to_net_t *this = xzalloc(sizeof(*this) + TO_NET_BUFSIZE); > - this->have_buffer_to_read_into = pty_to_net__have_buffer_to_read_into; > - this->have_data_to_write = pty_to_net__have_data_to_write; > - this->read = pty_to_net__read; > - this->write = pty_to_net__write; > + this->should_poll_read_fd = pty_to_net__should_poll_read_fd; > + this->should_poll_write_fd = pty_to_net__should_poll_write_fd; > + this->read = pty_to_net__read; > + this->write = pty_to_net__write; > this->read_fd = from; > this->write_fd = to; > /* indexes and size are all 0 */ > @@ -1013,10 +1013,10 @@ static int accept_conn__return_zero(void *this UNUSED_PARAM) > static struct accept_conn *new_accept_conn(int fd) > { > struct accept_conn *this = xzalloc(sizeof(*this)); > - this->have_buffer_to_read_into = accept_conn__can_accept; > - this->have_data_to_write = accept_conn__return_zero; > - this->read = accept_conn__accept; > - //this->write = accept_conn__return_zero; //never called > + this->should_poll_read_fd = accept_conn__can_accept; > + this->should_poll_write_fd = accept_conn__return_zero; > + this->read = accept_conn__accept; > + //this->write = accept_conn__return_zero; //never called > this->read_fd = fd; > this->write_fd = -1; > return this; > -- > 2.47.3 > > _______________________________________________ > busybox mailing list > [email protected] > https://lists.busybox.net/mailman/listinfo/busybox -- Guillermo Rodriguez Garcia [email protected] _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox