]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] stream_sock: don't clear FDs that are already cleared
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Nov 2010 22:08:17 +0000 (23:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Nov 2010 22:08:17 +0000 (23:08 +0100)
We can on average two calls to __fd_clr() per session by avoiding to
call it unnecessarily.

src/stream_sock.c

index 28ef81697daf88e3cab7c23dafec9d2e7825e7c1..598a1a02fa9d754a6642e73c410aadd520868cef 100644 (file)
@@ -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