From: Willy Tarreau Date: Sat, 23 Nov 2013 22:37:04 +0000 (+0100) Subject: MINOR: session: add a simple function to retrieve a session from a task X-Git-Tag: v1.5-dev20~138 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=787add29327c510d894dae62d2084939be99bfca;p=thirdparty%2Fhaproxy.git MINOR: session: add a simple function to retrieve a session from a task This function only casts t->context to (struct session *). It will avoid some ugly and unsafe casts in upcoming changes. --- diff --git a/include/proto/session.h b/include/proto/session.h index f597d59778..aaf4161582 100644 --- a/include/proto/session.h +++ b/include/proto/session.h @@ -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.