]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: session: add a simple function to retrieve a session from a task
authorWilly Tarreau <w@1wt.eu>
Sat, 23 Nov 2013 22:37:04 +0000 (23:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2013 14:40:21 +0000 (15:40 +0100)
This function only casts t->context to (struct session *). It will
avoid some ugly and unsafe casts in upcoming changes.

include/proto/session.h

index f597d5977892678bcb866334c188f14dc6df2e94..aaf4161582f95304c125d3952cd7b3763d871f9e 100644 (file)
@@ -50,6 +50,12 @@ int parse_track_counters(char **args, int *arg,
                         struct track_ctr_prm *prm,
                         struct proxy *defpx, char **err);
 
+/* returns the session from a void *owner */
+static inline struct session *session_from_task(struct task *t)
+{
+       return (struct session *)t->context;
+}
+
 /* 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.