From 11f49408f2654c832f12ce28d33cf9eac144ea09 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 11 Nov 2010 23:08:17 +0100 Subject: [PATCH] [OPTIM] stream_sock: don't clear FDs that are already cleared We can on average two calls to __fd_clr() per session by avoiding to call it unnecessarily. --- src/stream_sock.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/stream_sock.c b/src/stream_sock.c index 28ef81697d..598a1a02fa 100644 --- a/src/stream_sock.c +++ b/src/stream_sock.c @@ -938,10 +938,12 @@ void stream_sock_data_finish(struct stream_interface *si) /* Read not closed, update FD status and timeout for reads */ if (ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) { /* stop reading */ - if ((ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) == BF_FULL) - si->flags |= SI_FL_WAIT_ROOM; - EV_FD_COND_C(fd, DIR_RD); - ib->rex = TICK_ETERNITY; + if (!(si->flags & SI_FL_WAIT_ROOM)) { + if ((ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) == BF_FULL) + si->flags |= SI_FL_WAIT_ROOM; + EV_FD_COND_C(fd, DIR_RD); + ib->rex = TICK_ETERNITY; + } } else { /* (re)start reading and update timeout. Note: we don't recompute the timeout @@ -961,10 +963,12 @@ void stream_sock_data_finish(struct stream_interface *si) /* Write not closed, update FD status and timeout for writes */ if (ob->flags & BF_OUT_EMPTY) { /* stop writing */ - if ((ob->flags & (BF_FULL|BF_HIJACK|BF_SHUTW_NOW)) == 0) - si->flags |= SI_FL_WAIT_DATA; - EV_FD_COND_C(fd, DIR_WR); - ob->wex = TICK_ETERNITY; + if (!(si->flags & SI_FL_WAIT_DATA)) { + if ((ob->flags & (BF_FULL|BF_HIJACK|BF_SHUTW_NOW)) == 0) + si->flags |= SI_FL_WAIT_DATA; + EV_FD_COND_C(fd, DIR_WR); + ob->wex = TICK_ETERNITY; + } } else { /* (re)start writing and update timeout. Note: we don't recompute the timeout