]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mux-h2: use task_kill() during h2_takeover() instead of task_wakeup()
authorWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2020 14:39:33 +0000 (16:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2020 14:47:12 +0000 (16:47 +0200)
task_wakeup() passes the task through the global run queue under the
global RQ lock, which is expensive when dealing with large amounts of
h2_takeover() calls. Let's use the new task_kill() instead to kill the
task.

src/mux_h2.c

index 5fad272e78024a93723b5a798b750521fff4b21a..0ad066bd2908f43d5c96ba5f83748a7ba51c1b9a 100644 (file)
@@ -6050,6 +6050,7 @@ static void h2_show_fd(struct buffer *msg, struct connection *conn)
 static int h2_takeover(struct connection *conn)
 {
        struct h2c *h2c = conn->ctx;
+       struct task *task;
 
        if (fd_takeover(conn->handle.fd, conn) != 0)
                return -1;
@@ -6061,10 +6062,13 @@ static int h2_takeover(struct connection *conn)
         */
        h2c->wait_event.tasklet->context = NULL;
        tasklet_wakeup(h2c->wait_event.tasklet);
-       if (h2c->task) {
-               h2c->task->context = NULL;
-               /* Wake the task, to let it free itself */
-               task_wakeup(h2c->task, TASK_WOKEN_OTHER);
+
+       task = h2c->task;
+       if (task) {
+               task->context = NULL;
+               h2c->task = NULL;
+               __ha_barrier_store();
+               task_kill(task);
 
                h2c->task = task_new(tid_bit);
                if (!h2c->task) {