From 7f7ad910563d3ad1ef3ea2c5a05c747ccc796d90 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 11 Nov 2012 19:27:15 +0100 Subject: [PATCH] BUILD: stream_interface: remove si_fd() and its references si_fd() is not used a lot, and breaks builds on OpenBSD 5.2 which defines this name for its own purpose. It's easy enough to remove this one-liner function, so let's do it. --- include/proto/stream_interface.h | 5 ----- src/dumpstats.c | 8 ++++---- src/frontend.c | 2 +- src/proto_http.c | 7 ++++--- src/session.c | 13 +++++++------ src/stream_interface.c | 16 ++++++++-------- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 0d00fe2e8..9cc39f53f 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -56,11 +56,6 @@ static inline const struct protocol *si_ctrl(struct stream_interface *si) return si->conn->ctrl; } -static inline int si_fd(struct stream_interface *si) -{ - return si->conn->t.sock.fd; -} - static inline void si_prepare_conn(struct stream_interface *si, const struct protocol *ctrl, const struct xprt_ops *xprt) { si->ops = &si_conn_ops; diff --git a/src/dumpstats.c b/src/dumpstats.c index 0ee664164..306fc61db 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -3463,7 +3463,7 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si) &sess->si[0], sess->si[0].state, sess->si[0].flags, - si_fd(&sess->si[0]), + sess->si[0].conn->t.sock.fd, sess->si[0].exp ? tick_is_expired(sess->si[0].exp, now_ms) ? "" : human_time(TICKS_TO_MS(sess->si[0].exp - now_ms), @@ -3475,7 +3475,7 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si) &sess->si[1], sess->si[1].state, sess->si[1].flags, - si_fd(&sess->si[1]), + sess->si[1].conn->t.sock.fd, sess->si[1].exp ? tick_is_expired(sess->si[1].exp, now_ms) ? "" : human_time(TICKS_TO_MS(sess->si[1].exp - now_ms), @@ -3704,7 +3704,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si) " s0=[%d,%1xh,fd=%d,ex=%s]", curr_sess->si[0].state, curr_sess->si[0].flags, - si_fd(&curr_sess->si[0]), + curr_sess->si[0].conn->t.sock.fd, curr_sess->si[0].exp ? human_time(TICKS_TO_MS(curr_sess->si[0].exp - now_ms), TICKS_TO_MS(1000)) : ""); @@ -3713,7 +3713,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si) " s1=[%d,%1xh,fd=%d,ex=%s]", curr_sess->si[1].state, curr_sess->si[1].flags, - si_fd(&curr_sess->si[1]), + curr_sess->si[1].conn->t.sock.fd, curr_sess->si[1].exp ? human_time(TICKS_TO_MS(curr_sess->si[1].exp - now_ms), TICKS_TO_MS(1000)) : ""); diff --git a/src/frontend.c b/src/frontend.c index 652718c73..a85cccee0 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -52,7 +52,7 @@ */ int frontend_accept(struct session *s) { - int cfd = si_fd(&s->si[0]); + int cfd = s->si[0].conn->t.sock.fd; tv_zero(&s->logs.tv_request); s->logs.t_queue = -1; diff --git a/src/proto_http.c b/src/proto_http.c index d768b87ac..8e96ae684 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -2392,7 +2392,7 @@ int http_wait_for_request(struct session *s, struct channel *req, int an_bit) * previously disabled it, otherwise we might cause the client * to delay next data. */ - setsockopt(si_fd(&s->si[0]), IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one)); + setsockopt(s->si[0].conn->t.sock.fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one)); } #endif @@ -3706,7 +3706,7 @@ int http_process_request(struct session *s, struct channel *req, int an_bit) if ((s->listener->options & LI_O_NOQUICKACK) && ((msg->flags & HTTP_MSGF_TE_CHNK) || (msg->body_len > req->buf->i - txn->req.eoh - 2))) - setsockopt(si_fd(&s->si[0]), IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one)); + setsockopt(s->si[0].conn->t.sock.fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one)); #endif } @@ -7657,7 +7657,8 @@ void debug_hdr(const char *dir, struct session *t, const char *start, const char { int max; chunk_printf(&trash, "%08x:%s.%s[%04x:%04x]: ", t->uniq_id, t->be->id, - dir, (unsigned short)si_fd(t->req->prod), (unsigned short)si_fd(t->req->cons)); + dir, (unsigned short)t->req->prod->conn->t.sock.fd, + (unsigned short)t->req->cons->conn->t.sock.fd); for (max = 0; start + max < end; max++) if (start[max] == '\r' || start[max] == '\n') diff --git a/src/session.c b/src/session.c index 6bb44f021..772adf6b5 100644 --- a/src/session.c +++ b/src/session.c @@ -778,7 +778,7 @@ static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si } si->exp = TICK_ETERNITY; si->state = SI_ST_CER; - fd_delete(si_fd(si)); + fd_delete(si->conn->t.sock.fd); conn_xprt_close(si->conn); if (si->release) @@ -2322,8 +2322,8 @@ struct task *process_session(struct task *t) s->si[1].prev_state == SI_ST_EST) { chunk_printf(&trash, "%08x:%s.srvcls[%04x:%04x]\n", s->uniq_id, s->be->id, - (unsigned short)si_fd(&s->si[0]), - (unsigned short)si_fd(&s->si[1])); + (unsigned short)s->si[0].conn->t.sock.fd, + (unsigned short)s->si[1].conn->t.sock.fd); if (write(1, trash.str, trash.len) < 0) /* shut gcc warning */; } @@ -2331,8 +2331,8 @@ struct task *process_session(struct task *t) s->si[0].prev_state == SI_ST_EST) { chunk_printf(&trash, "%08x:%s.clicls[%04x:%04x]\n", s->uniq_id, s->be->id, - (unsigned short)si_fd(&s->si[0]), - (unsigned short)si_fd(&s->si[1])); + (unsigned short)s->si[0].conn->t.sock.fd, + (unsigned short)s->si[1].conn->t.sock.fd); if (write(1, trash.str, trash.len) < 0) /* shut gcc warning */; } } @@ -2439,7 +2439,8 @@ struct task *process_session(struct task *t) (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) { chunk_printf(&trash, "%08x:%s.closed[%04x:%04x]\n", s->uniq_id, s->be->id, - (unsigned short)si_fd(s->req->prod), (unsigned short)si_fd(s->req->cons)); + (unsigned short)s->req->prod->conn->t.sock.fd, + (unsigned short)s->req->cons->conn->t.sock.fd); if (write(1, trash.str, trash.len) < 0) /* shut gcc warning */; } diff --git a/src/stream_interface.c b/src/stream_interface.c index 5a7bbc6f1..8e1fd98dc 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -248,7 +248,7 @@ int stream_int_shutr(struct stream_interface *si) if (si->ob->flags & CF_SHUTW) { conn_xprt_close(si->conn); if (conn->ctrl) - fd_delete(si_fd(si)); + fd_delete(si->conn->t.sock.fd); si->state = SI_ST_DIS; si->exp = TICK_ETERNITY; @@ -307,7 +307,7 @@ int stream_int_shutw(struct stream_interface *si) } else if (si->flags & SI_FL_NOLINGER) { si->flags &= ~SI_FL_NOLINGER; if (conn->ctrl) { - setsockopt(si_fd(si), SOL_SOCKET, SO_LINGER, + setsockopt(si->conn->t.sock.fd, SOL_SOCKET, SO_LINGER, (struct linger *) &nolinger, sizeof(struct linger)); } /* unclean data-layer shutdown */ @@ -321,7 +321,7 @@ int stream_int_shutw(struct stream_interface *si) if (!(si->flags & SI_FL_NOHALF)) { /* We shutdown transport layer */ if (conn->ctrl) - shutdown(si_fd(si), SHUT_WR); + shutdown(si->conn->t.sock.fd, SHUT_WR); if (!(si->ib->flags & (CF_SHUTR|CF_DONT_READ))) { /* OK just a shutw, but we want the caller @@ -339,7 +339,7 @@ int stream_int_shutw(struct stream_interface *si) */ conn_xprt_close(si->conn); if (conn->ctrl) - fd_delete(si_fd(si)); + fd_delete(si->conn->t.sock.fd); /* fall through */ case SI_ST_CER: case SI_ST_QUE: @@ -857,14 +857,14 @@ static void stream_int_chk_snd_conn(struct stream_interface *si) if (!ob->pipe && /* spliced data wants to be forwarded ASAP */ (!(si->flags & SI_FL_WAIT_DATA) || /* not waiting for data */ - (fdtab[si_fd(si)].ev & FD_POLL_OUT))) /* we'll be called anyway */ + (fdtab[si->conn->t.sock.fd].ev & FD_POLL_OUT))) /* we'll be called anyway */ return; if (!(si->conn->flags & CO_FL_HANDSHAKE) && si_conn_send_loop(si->conn) < 0) { /* Write error on the file descriptor. We mark the FD as STERROR so * that we don't use it anymore and we notify the task. */ - fdtab[si_fd(si)].ev &= ~FD_POLL_STICKY; + fdtab[si->conn->t.sock.fd].ev &= ~FD_POLL_STICKY; __conn_data_stop_both(si->conn); si->flags |= SI_FL_ERR; si->conn->flags |= CO_FL_ERROR; @@ -1207,7 +1207,7 @@ void stream_sock_read0(struct stream_interface *si) /* we want to immediately forward this close to the write side */ if (si->flags & SI_FL_NOLINGER) { si->flags &= ~SI_FL_NOLINGER; - setsockopt(si_fd(si), SOL_SOCKET, SO_LINGER, + setsockopt(si->conn->t.sock.fd, SOL_SOCKET, SO_LINGER, (struct linger *) &nolinger, sizeof(struct linger)); } /* force flag on ssl to keep session in cache */ @@ -1222,7 +1222,7 @@ void stream_sock_read0(struct stream_interface *si) do_close: conn_xprt_close(si->conn); - fd_delete(si_fd(si)); + fd_delete(si->conn->t.sock.fd); si->state = SI_ST_DIS; si->exp = TICK_ETERNITY; if (si->release)