]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stick-table: remove the unused table->exp_next
authorWilly Tarreau <w@1wt.eu>
Mon, 14 Nov 2022 16:33:02 +0000 (17:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Nov 2022 17:20:38 +0000 (18:20 +0100)
The ->exp_next field of the stick-table was probably useful in 1.5 but
it currently only carries a copy of what the future value of the table's
task's expire value will be, while it's systematically copied over there
immediately after being assigned. As such it provides exactly a local
variable. Let's remove it, as it costs atomic operations.

include/haproxy/stick_table-t.h
src/stick_table.c

index 54b27bb4f5ad1d225c357e0f8f4cff33246b0336..cc9fe93576db2674dcc28dd3c57805c9aef9d3b9 100644 (file)
@@ -185,7 +185,6 @@ struct stktable {
        unsigned int size;        /* maximum number of sticky sessions in table */
        unsigned int current;     /* number of sticky sessions currently in table */
        int nopurge;              /* if non-zero, don't purge sticky sessions when full */
-       int exp_next;             /* next expiration date (ticks) */
        int expire;               /* time to live for sticky sessions (milliseconds) */
        int data_size;            /* the size of the data that is prepended *before* stksess */
        int data_ofs[STKTABLE_DATA_TYPES]; /* negative offsets of present data types, or 0 if absent */
index 77a5ba52310143a5f04aa12edc7575706f269ad6..61e63b8ae68a5405f0a14f79b3267cf97be930f3 100644 (file)
@@ -548,19 +548,10 @@ void stktable_requeue_exp(struct stktable *t, const struct stksess *ts)
        if (!t->expire)
                return;
 
-       /* set both t->exp_next and the task's expire to the newest
-        * expiration date.
-        */
-       old_exp = HA_ATOMIC_LOAD(&t->exp_next);
-       do {
-               new_exp = tick_first(expire, old_exp);
-       } while (new_exp != old_exp &&
-                !HA_ATOMIC_CAS(&t->exp_next, &old_exp, new_exp) &&
-                __ha_cpu_relax());
-
+       /* set the task's expire to the newest expiration date. */
        old_exp = HA_ATOMIC_LOAD(&t->exp_task->expire);
        do {
-               new_exp = HA_ATOMIC_LOAD(&t->exp_next);
+               new_exp = tick_first(expire, old_exp);
        } while (new_exp != old_exp &&
                 !HA_ATOMIC_CAS(&t->exp_task->expire, &old_exp, new_exp) &&
                 __ha_cpu_relax());
@@ -664,6 +655,7 @@ static int stktable_trash_expired(struct stktable *t)
        struct stksess *ts;
        struct eb32_node *eb;
        int looped = 0;
+       int exp_next;
 
        HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
        eb = eb32_lookup_ge(&t->exps, now_ms - TIMER_LOOK_BACK);
@@ -685,7 +677,7 @@ static int stktable_trash_expired(struct stktable *t)
 
                if (likely(tick_is_lt(now_ms, eb->key))) {
                        /* timer not expired yet, revisit it later */
-                       t->exp_next = eb->key;
+                       exp_next = eb->key;
                        goto out_unlock;
                }
 
@@ -718,10 +710,10 @@ static int stktable_trash_expired(struct stktable *t)
        }
 
        /* We have found no task to expire in any tree */
-       t->exp_next = TICK_ETERNITY;
+       exp_next = TICK_ETERNITY;
 out_unlock:
        HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);
-       return t->exp_next;
+       return exp_next;
 }
 
 /*
@@ -748,7 +740,6 @@ int stktable_init(struct stktable *t)
 
                t->pool = create_pool("sticktables", sizeof(struct stksess) + round_ptr_size(t->data_size) + t->key_size, MEM_F_SHARED);
 
-               t->exp_next = TICK_ETERNITY;
                if ( t->expire ) {
                        t->exp_task = task_new_anywhere();
                        if (!t->exp_task)