From aefd79004cd51a260723b5def4caa09d27ea597a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 28 Nov 2014 12:03:32 +0100 Subject: [PATCH] MEDIUM: stream-int: make si_sess() use the stream int's side This one relies on the SI's side to find the pointer to the session. That the stream interface doesn't have to look at the task's context anymore. --- include/proto/stream_interface.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index cc79e6ddd..4d5abcf2a 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -64,6 +64,15 @@ static inline struct channel *si_oc(struct stream_interface *si) return &LIST_ELEM(si, struct session *, si[0])->res; } +/* returns the session associated to a stream interface */ +static inline struct session *si_sess(struct stream_interface *si) +{ + if (si->flags & SI_FL_ISBACK) + return LIST_ELEM(si, struct session *, si[1]); + else + return LIST_ELEM(si, struct session *, si[0]); +} + /* Initializes all required fields for a new appctx. Note that it does the * minimum acceptable initialization for an appctx. This means only the * 3 integer states st0, st1, st2 are zeroed. @@ -365,12 +374,6 @@ static inline int si_connect(struct stream_interface *si) return ret; } -/* finds the session which owns a stream interface */ -static inline struct session *si_sess(struct stream_interface *si) -{ - return (struct session *)((struct task *)si->owner)->context; -} - /* for debugging, reports the stream interface state name */ static inline const char *si_state_str(int state) {