]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: connections: rename the toremove_lock to takeover_lock
authorOlivier Houchard <cognet@ci0.org>
Mon, 29 Jun 2020 18:15:59 +0000 (20:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2020 15:09:10 +0000 (17:09 +0200)
This lock was misnamed and a bit confusing. It's only used for takeover
so let's call it takeover_lock.

include/haproxy/connection-t.h
include/haproxy/connection.h
src/backend.c
src/cfgparse.c
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/server.c

index 1ff1c93818ba93fc1f2976133943f50fd2c93763..8b48c9815ddbf9467005295c2b132ad577ce05e5 100644 (file)
@@ -606,7 +606,7 @@ struct tlv_ssl {
  */
 struct idle_conns {
        struct mt_list toremove_conns;
-       __decl_thread(HA_SPINLOCK_T toremove_lock);
+       __decl_thread(HA_SPINLOCK_T takeover_lock);
        struct task *cleanup_task;
 } THREAD_ALIGNED(64);
 
index a7b942cebc4e6153fa43508f48ad2c748d1433c7..6e8862b07dbc47b37482ab040a043ff8e775b8bc 100644 (file)
@@ -494,9 +494,9 @@ static inline void conn_free(struct connection *conn)
        }
 
        conn_force_unsubscribe(conn);
-       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        MT_LIST_DEL((struct mt_list *)&conn->list);
-       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        pool_free(pool_head_connection, conn);
 }
 
index 97c3231d5103d860c26f40e6dfaeb6fbc7056922..0b4cb4c9383d0e94afd17ee1bda2a49567c00e6d 100644 (file)
@@ -1086,7 +1086,7 @@ static struct connection *conn_backend_get(struct server *srv, int is_safe)
         * to end up with two threads using the same connection.
         */
        i = tid;
-       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        conn = MT_LIST_POP(&mt_list[tid], struct connection *, list);
 
        /* If we failed to pick a connection from the idle list, let's try again with
@@ -1099,7 +1099,7 @@ static struct connection *conn_backend_get(struct server *srv, int is_safe)
                        mt_list = srv->safe_conns;
                }
        }
-       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
        /* If we found a connection in our own list, and we don't have to
         * steal one from another thread, then we're done.
@@ -1129,7 +1129,7 @@ static struct connection *conn_backend_get(struct server *srv, int is_safe)
                if (!srv->curr_idle_thr[i] || i == tid)
                        continue;
 
-               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[i].toremove_lock);
+               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[i].takeover_lock);
                mt_list_for_each_entry_safe(conn, &mt_list[i], list, elt1, elt2) {
                        if (conn->mux->takeover && conn->mux->takeover(conn) == 0) {
                                MT_LIST_DEL_SAFE(elt1);
@@ -1151,7 +1151,7 @@ static struct connection *conn_backend_get(struct server *srv, int is_safe)
                                }
                        }
                }
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[i].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[i].takeover_lock);
        }
 
        if (!found)
@@ -1328,7 +1328,7 @@ int connect_server(struct stream *s)
                                // see it possibly larger.
                                ALREADY_CHECKED(i);
 
-                               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+                               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                                tokill_conn = MT_LIST_POP(&srv->idle_conns[i],
                                    struct connection *, list);
                                if (!tokill_conn)
@@ -1340,10 +1340,10 @@ int connect_server(struct stream *s)
                                        MT_LIST_ADDQ(&idle_conns[i].toremove_conns,
                                            (struct mt_list *)&tokill_conn->list);
                                        task_wakeup(idle_conns[i].cleanup_task, TASK_WOKEN_OTHER);
-                                       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+                                       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                                        break;
                                }
-                               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+                               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                        }
                }
 
index e3f3d9fae6f9a6e75be0516230d553405b947745..443c40674d560a3cb071feeac3858d2e2931cf38 100644 (file)
@@ -3571,7 +3571,7 @@ out_uri_auth_compat:
                                                        goto err;
                                                idle_conns[i].cleanup_task->process = srv_cleanup_toremove_connections;
                                                idle_conns[i].cleanup_task->context = NULL;
-                                               HA_SPIN_INIT(&idle_conns[i].toremove_lock);
+                                               HA_SPIN_INIT(&idle_conns[i].takeover_lock);
                                                MT_LIST_INIT(&idle_conns[i].toremove_conns);
                                        }
                                }
index bd27a63f00aa39bce88ce8962234b215f4bcf58c..1cf8a33b4137f8131fbd2aee6a5fd604602812b8 100644 (file)
@@ -2918,13 +2918,13 @@ static struct task *fcgi_io_cb(struct task *t, void *ctx, unsigned short status)
        int ret = 0;
 
 
-       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        if (tl->context == NULL) {
                /* The connection has been taken over by another thread,
                 * we're no longer responsible for it, so just free the
                 * tasklet, and do nothing.
                 */
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                tasklet_free(tl);
                return NULL;
 
@@ -2938,7 +2938,7 @@ static struct task *fcgi_io_cb(struct task *t, void *ctx, unsigned short status)
        if (conn_in_list)
                MT_LIST_DEL(&conn->list);
 
-       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
        if (!(fconn->wait_event.events & SUB_RETRY_SEND))
                ret = fcgi_send(fconn);
@@ -3093,7 +3093,7 @@ static struct task *fcgi_timeout_task(struct task *t, void *context, unsigned sh
                /* We're about to destroy the connection, so make sure nobody attempts
                 * to steal it from us.
                 */
-               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
                if (fconn->conn->flags & CO_FL_LIST_MASK)
                        MT_LIST_DEL(&fconn->conn->list);
@@ -3104,7 +3104,7 @@ static struct task *fcgi_timeout_task(struct task *t, void *context, unsigned sh
                if (!t->context)
                        fconn = NULL;
 
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        }
 
        task_destroy(t);
index ace04cb68f31193ef1bebae38ddb2b8108c7e24c..a294c6542cb4ebc986c372a0aec9af825d527993 100644 (file)
@@ -2219,13 +2219,13 @@ static struct task *h1_io_cb(struct task *t, void *ctx, unsigned short status)
        int ret = 0;
 
 
-       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        if (tl->context == NULL) {
                /* The connection has been taken over by another thread,
                 * we're no longer responsible for it, so just free the
                 * tasklet, and do nothing.
                 */
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                tasklet_free(tl);
                return NULL;
        }
@@ -2241,7 +2241,7 @@ static struct task *h1_io_cb(struct task *t, void *ctx, unsigned short status)
        if (conn_in_list)
                MT_LIST_DEL(&conn->list);
 
-       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
        if (!(h1c->wait_event.events & SUB_RETRY_SEND))
                ret = h1_send(h1c);
@@ -2309,7 +2309,7 @@ static struct task *h1_timeout_task(struct task *t, void *context, unsigned shor
                /* We're about to destroy the connection, so make sure nobody attempts
                 * to steal it from us.
                 */
-               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
                if (h1c->conn->flags & CO_FL_LIST_MASK)
                        MT_LIST_DEL(&h1c->conn->list);
@@ -2320,7 +2320,7 @@ static struct task *h1_timeout_task(struct task *t, void *context, unsigned shor
                if (!t->context)
                        h1c = NULL;
 
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        }
 
        task_destroy(t);
index 0ad066bd2908f43d5c96ba5f83748a7ba51c1b9a..adcc6c270dd7ee5c2632cdfee9dfa833cb917d11 100644 (file)
@@ -3524,13 +3524,13 @@ static struct task *h2_io_cb(struct task *t, void *ctx, unsigned short status)
        int ret = 0;
 
 
-       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        if (t->context == NULL) {
                /* The connection has been taken over by another thread,
                 * we're no longer responsible for it, so just free the
                 * tasklet, and do nothing.
                 */
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                tasklet_free(tl);
                goto leave;
        }
@@ -3547,7 +3547,7 @@ static struct task *h2_io_cb(struct task *t, void *ctx, unsigned short status)
        if (conn_in_list)
                MT_LIST_DEL(&conn->list);
 
-       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
        if (!(h2c->wait_event.events & SUB_RETRY_SEND))
                ret = h2_send(h2c);
@@ -3643,15 +3643,15 @@ static int h2_process(struct h2c *h2c)
                }
 
                /* connections in error must be removed from the idle lists */
-               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                MT_LIST_DEL((struct mt_list *)&conn->list);
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        }
        else if (h2c->st0 == H2_CS_ERROR) {
                /* connections in error must be removed from the idle lists */
-               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
                MT_LIST_DEL((struct mt_list *)&conn->list);
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        }
 
        if (!b_data(&h2c->dbuf))
@@ -3722,7 +3722,7 @@ static struct task *h2_timeout_task(struct task *t, void *context, unsigned shor
                /* We're about to destroy the connection, so make sure nobody attempts
                 * to steal it from us.
                 */
-               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
                if (h2c->conn->flags & CO_FL_LIST_MASK)
                        MT_LIST_DEL(&h2c->conn->list);
@@ -3733,7 +3733,7 @@ static struct task *h2_timeout_task(struct task *t, void *context, unsigned shor
                if (!t->context)
                        h2c = NULL;
 
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        }
 
        task_destroy(t);
@@ -3780,9 +3780,9 @@ static struct task *h2_timeout_task(struct task *t, void *context, unsigned shor
        }
 
        /* in any case this connection must not be considered idle anymore */
-       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
        MT_LIST_DEL((struct mt_list *)&h2c->conn->list);
-       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
+       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].takeover_lock);
 
        /* either we can release everything now or it will be done later once
         * the last stream closes.
index 4c2eb77473f330ccbe8a6bd2971d2faf7f26328e..a6824f757478101659bea993066143ebdbefc755 100644 (file)
@@ -5207,7 +5207,7 @@ static void srv_cleanup_connections(struct server *srv)
        HA_SPIN_LOCK(OTHER_LOCK, &idle_conn_srv_lock);
        for (i = tid;;) {
                did_remove = 0;
-               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[i].toremove_lock);
+               HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[i].takeover_lock);
                for (j = 0; j < srv->curr_idle_conns; j++) {
                        conn = MT_LIST_POP(&srv->idle_conns[i], struct connection *, list);
                        if (!conn)
@@ -5218,7 +5218,7 @@ static void srv_cleanup_connections(struct server *srv)
                        did_remove = 1;
                        MT_LIST_ADDQ(&idle_conns[i].toremove_conns, (struct mt_list *)&conn->list);
                }
-               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[i].toremove_lock);
+               HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[i].takeover_lock);
                if (did_remove)
                        task_wakeup(idle_conns[i].cleanup_task, TASK_WOKEN_OTHER);
 
@@ -5287,7 +5287,7 @@ struct task *srv_cleanup_idle_connections(struct task *task, void *context, unsi
 
                        max_conn = (exceed_conns * srv->curr_idle_thr[i]) /
                                   curr_idle + 1;
-                       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[i].toremove_lock);
+                       HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[i].takeover_lock);
                        for (j = 0; j < max_conn; j++) {
                                struct connection *conn = MT_LIST_POP(&srv->idle_conns[i], struct connection *, list);
                                if (!conn)
@@ -5298,7 +5298,7 @@ struct task *srv_cleanup_idle_connections(struct task *task, void *context, unsi
                                did_remove = 1;
                                MT_LIST_ADDQ(&idle_conns[i].toremove_conns, (struct mt_list *)&conn->list);
                        }
-                       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[i].toremove_lock);
+                       HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[i].takeover_lock);
                        if (did_remove && max_conn < srv->curr_idle_thr[i])
                                srv_is_empty = 0;
                        if (did_remove)