[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.
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 28ef816..598a1a0 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -938,10 +938,12 @@
/* 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 @@
/* 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