]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: session: update the session's stick counters upon session_free()
authorWilly Tarreau <w@1wt.eu>
Sat, 4 Apr 2015 14:31:16 +0000 (16:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Apr 2015 09:37:31 +0000 (11:37 +0200)
Whenever session_free() is called, any possible stick counter stored in
the session will be synchronized.

include/proto/session.h
src/session.c

index 487f318ecd235876a919cbc05441e68e87c38039..6d45d580593d12d13143c554f894fb3cb4b2a6be 100644 (file)
 #include <types/global.h>
 #include <types/session.h>
 
+#include <proto/stick_table.h>
+
 extern struct pool_head *pool2_session;
 void session_free(struct session *sess);
 int init_session();
 
+/* Remove the refcount from the session to the tracked counters, and clear the
+ * pointer to ensure this is only performed once. The caller is responsible for
+ * ensuring that the pointer is valid first.
+ */
+static inline void session_store_counters(struct session *sess)
+{
+       void *ptr;
+       int i;
+
+       for (i = 0; i < MAX_SESS_STKCTR; i++) {
+               struct stkctr *stkctr = &sess->stkctr[i];
+
+               if (!stkctr_entry(stkctr))
+                       continue;
+
+               ptr = stktable_data_ptr(stkctr->table, stkctr_entry(stkctr), STKTABLE_DT_CONN_CUR);
+               if (ptr)
+                       stktable_data_cast(ptr, conn_cur)--;
+               stkctr_entry(stkctr)->ref_cnt--;
+               stksess_kill_if_expired(stkctr->table, stkctr_entry(stkctr));
+               stkctr_set_entry(stkctr, NULL);
+       }
+}
+
+
 #endif /* _PROTO_SESSION_H */
 
 /*
index e1e9f352daccc6aa81bf392e134c21ed0ec99c89..caf8c1439f5f9f1e2066d541ade76a87cf0af1a4 100644 (file)
 #include <types/global.h>
 #include <types/session.h>
 
+#include <proto/session.h>
+
 struct pool_head *pool2_session;
 
 void session_free(struct session *sess)
 {
+       session_store_counters(sess);
        pool_free2(pool2_session, sess);
 }