From: Willy Tarreau Date: Thu, 11 Apr 2013 14:55:37 +0000 (+0200) Subject: MINOR: stick-table: allow to allocate an entry without filling it X-Git-Tag: v1.5-dev19~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7b46b50d9bb723f3bd3759c98130fbdd790158b;p=thirdparty%2Fhaproxy.git MINOR: stick-table: allow to allocate an entry without filling it By passing a NULL key to stksess_new(), we allocate it but do not yet fill it. That way the caller can do that. --- diff --git a/src/stick_table.c b/src/stick_table.c index 52a58665ed..3097e662fe 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -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 sticky session counter. + * stksess_free(). Table 's sticky session counter is increased. If + * 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;