]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-int: make si_sess() use the stream int's side
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Nov 2014 11:03:32 +0000 (12:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Mar 2015 19:41:46 +0000 (20:41 +0100)
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

index cc79e6ddda3382c099b9b60ff5dac70e7e66c5c7..4d5abcf2af5dea26391865f6780e4955337ef498 100644 (file)
@@ -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)
 {