]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: don't re-enable the connection's task when we're closing
authorWilly Tarreau <w@1wt.eu>
Tue, 7 Nov 2017 10:59:51 +0000 (11:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 Nov 2017 13:47:04 +0000 (14:47 +0100)
It's pointless to requeue the task when we're closing, so swap the
order of the task_queue() and h2_release(). It also matches what
was written in the comment regarding re-arming the timer.

src/mux_h2.c

index b241a5b53a6a49ab67d10e7a7f532add19b6fc19..e1c995516c6e2d422bff65f737cad6e85c74afb4 100644 (file)
@@ -2195,20 +2195,10 @@ static void h2_detach(struct conn_stream *cs)
                /* h2s still attached to the h2c */
                eb32_delete(&h2s->by_id);
 
-               if (h2c->task) {
-                       if (eb_is_empty(&h2c->streams_by_id)) {
-                               h2c->task->expire = tick_add(now_ms, h2c->timeout);
-                               task_queue(h2c->task);
-                       }
-                       else
-                               h2c->task->expire = TICK_ETERNITY;
-               }
-
                /* We don't want to close right now unless we're removing the
                 * last stream, and either the connection is in error, or it
                 * reached the ID already specified in a GOAWAY frame received
-                * or sent (as seen by last_sid >= 0). A timer should be armed
-                * to kill the connection after some idle time though.
+                * or sent (as seen by last_sid >= 0).
                 */
                if (eb_is_empty(&h2c->streams_by_id) &&     /* don't close if streams exist */
                    ((h2c->conn->flags & CO_FL_ERROR) ||    /* errors close immediately */
@@ -2219,6 +2209,14 @@ static void h2_detach(struct conn_stream *cs)
                        /* no more stream will come, kill it now */
                        h2_release(h2c->conn);
                }
+               else if (h2c->task) {
+                       if (eb_is_empty(&h2c->streams_by_id)) {
+                               h2c->task->expire = tick_add(now_ms, h2c->timeout);
+                               task_queue(h2c->task);
+                       }
+                       else
+                               h2c->task->expire = TICK_ETERNITY;
+               }
        }
        pool_free2(pool2_h2s, h2s);
 }