[MEDIUM] session counters: automatically remove expired entries.

When a ref_cnt goes down to zero and the entry is expired, remove it.
diff --git a/include/proto/session.h b/include/proto/session.h
index 0959320..bf390ca 100644
--- a/include/proto/session.h
+++ b/include/proto/session.h
@@ -60,6 +60,7 @@
 		if (ptr)
 			stktable_data_cast(ptr, conn_cur)--;
 		s->be_tracked_counters->ref_cnt--;
+		stksess_kill_if_expired(s->be_tracked_table, s->be_tracked_counters);
 		s->be_tracked_counters = NULL;
 	}
 
@@ -68,6 +69,7 @@
 		if (ptr)
 			stktable_data_cast(ptr, conn_cur)--;
 		s->fe_tracked_counters->ref_cnt--;
+		stksess_kill_if_expired(s->fe_tracked_table, s->fe_tracked_counters);
 		s->fe_tracked_counters = NULL;
 	}
 }
@@ -87,6 +89,7 @@
 	if (ptr)
 		stktable_data_cast(ptr, conn_cur)--;
 	s->be_tracked_counters->ref_cnt--;
+	stksess_kill_if_expired(s->be_tracked_table, s->be_tracked_counters);
 	s->be_tracked_counters = NULL;
 }
 
diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h
index e702356..583e32a 100644
--- a/include/proto/stick_table.h
+++ b/include/proto/stick_table.h
@@ -24,6 +24,8 @@
 #define _PROTO_STICK_TABLE_H
 
 #include <common/errors.h>
+#include <common/ticks.h>
+#include <common/time.h>
 #include <types/stick_table.h>
 
 #define stktable_data_size(type) (sizeof(((union stktable_data*)0)->type))
@@ -34,6 +36,7 @@
 struct stksess *stksess_new(struct stktable *t, struct stktable_key *key);
 void stksess_setkey(struct stktable *t, struct stksess *ts, struct stktable_key *key);
 void stksess_free(struct stktable *t, struct stksess *ts);
+void stksess_kill(struct stktable *t, struct stksess *ts);
 
 int stktable_init(struct stktable *t);
 int stktable_parse_type(char **args, int *idx, unsigned long *type, size_t *key_size);
@@ -122,4 +125,11 @@
 	return (void *)ts + t->data_ofs[type];
 }
 
+/* kill an entry if it's expired and its ref_cnt is zero */
+static inline void stksess_kill_if_expired(struct stktable *t, struct stksess *ts)
+{
+	if (tick_is_expired(ts->expire, now_ms))
+		stksess_kill(t, ts);
+}
+
 #endif /* _PROTO_STICK_TABLE_H */