]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: move the applet_pause call out of the stream updates
authorWilly Tarreau <w@1wt.eu>
Wed, 23 Sep 2015 17:55:42 +0000 (19:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Sep 2015 16:07:16 +0000 (18:07 +0200)
It's just to split the part dealing with the stream update and the part
dealing with the applet update in si_applet_done().

src/stream_interface.c

index 2de7740ab0e3acb7ee1b3a46730f9b5492411df9..4c41d036dae26a23788cbb0b64ada4d0be0d3acb 100644 (file)
@@ -1443,11 +1443,6 @@ void si_applet_done(struct stream_interface *si)
                        ic->rex = tick_add_ifset(now_ms, ic->rto);
        }
 
-       /* get away from the active list if we can't work anymore. */
-       if (((si->flags & (SI_FL_WANT_PUT|SI_FL_WAIT_ROOM)) != SI_FL_WANT_PUT) &&
-           ((si->flags & (SI_FL_WANT_GET|SI_FL_WAIT_DATA)) != SI_FL_WANT_GET))
-               appctx_pause(si_appctx(si));
-
        /* wake the task up only when needed */
        if (/* changes on the production side */
            (ic->flags & (CF_READ_NULL|CF_READ_ERROR)) ||
@@ -1464,12 +1459,22 @@ void si_applet_done(struct stream_interface *si)
               (si_opposite(si)->state != SI_ST_EST ||
                (channel_is_empty(oc) && !oc->to_forward)))))) {
                task_wakeup(si_task(si), TASK_WOKEN_IO);
-               appctx_pause(si_appctx(si));
        }
+
        if (ic->flags & CF_READ_ACTIVITY)
                ic->flags &= ~CF_READ_DONTWAIT;
 
        stream_release_buffers(si_strm(si));
+
+       /* Get away from the active list if we can't work anymore.
+        * We also do that if the main task has already scheduled, because it
+        * saves a useless wakeup/pause/wakeup cycle causing one useless call
+        * per session on average.
+        */
+       if (task_in_rq(si_task(si)) ||
+           (((si->flags & (SI_FL_WANT_PUT|SI_FL_WAIT_ROOM)) != SI_FL_WANT_PUT) &&
+            ((si->flags & (SI_FL_WANT_GET|SI_FL_WAIT_DATA)) != SI_FL_WANT_GET)))
+               appctx_pause(si_appctx(si));
 }