]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel: add chn_sess() helper to retrieve session from channel
authorWilly Tarreau <w@1wt.eu>
Sun, 28 Dec 2014 12:03:53 +0000 (13:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Mar 2015 19:41:47 +0000 (20:41 +0100)
Channels already have to know what session they below to. Add a helper
to retrieve this pointer so that we'll use it later.

include/proto/channel.h

index 05084bb66d0ce9706f67550333d752929e3cf68c..9907a51d6c368d46183f8d9eea10593a212f6771 100644 (file)
@@ -54,6 +54,15 @@ int bo_getline_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int
 int bo_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
 
 
+/* returns a pointer to the session the channel belongs to */
+static inline struct session *chn_sess(const struct channel *chn)
+{
+       if (chn->flags & CF_ISRESP)
+               return LIST_ELEM(chn, struct session *, res);
+       else
+               return LIST_ELEM(chn, struct session *, req);
+}
+
 /* returns a pointer to the stream interface feeding the channel (producer) */
 static inline struct stream_interface *chn_prod(const struct channel *chn)
 {