]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stick-table: allow to allocate an entry without filling it
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2013 14:55:37 +0000 (16:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2013 15:24:53 +0000 (17:24 +0200)
By passing a NULL key to stksess_new(), we allocate it but do not yet
fill it. That way the caller can do that.

src/stick_table.c

index 52a58665ed21f709407116e3fd5a8236c51c666f..3097e662fe1613178e6e2d561c101f2852acd85c 100644 (file)
@@ -152,7 +152,8 @@ static int stktable_trash_oldest(struct stktable *t, int to_batch)
  * Allocate and initialise a new sticky session.
  * The new sticky session is returned or NULL in case of lack of memory.
  * Sticky sessions should only be allocated this way, and must be freed using
- * stksess_free(). Increase table <t> sticky session counter.
+ * stksess_free(). Table <t>'s sticky session counter is increased. If <key>
+ * is not NULL, it is assigned to the new session.
  */
 struct stksess *stksess_new(struct stktable *t, struct stktable_key *key)
 {
@@ -170,7 +171,8 @@ struct stksess *stksess_new(struct stktable *t, struct stktable_key *key)
        if (ts) {
                t->current++;
                stksess_init(t, ts);
-               stksess_setkey(t, ts, key);
+               if (key)
+                       stksess_setkey(t, ts, key);
        }
 
        return ts;