]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream_interface: add a pointer to the listener for TARG_TYPE_CLIENT
authorEmeric Brun <ebrun@exceliance.fr>
Fri, 18 May 2012 14:32:13 +0000 (16:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 21 May 2012 20:22:39 +0000 (22:22 +0200)
When the target is a client, it will be convenient to have a pointer to the
original listener so that we can retrieve some configuration information at
the stream interface level.

include/proto/stream_interface.h
include/types/stream_interface.h
src/peers.c
src/session.c

index efdb1c48b1f9106e3d8da1e661d9fdbb04fcc3c0..7f1cb9e97d79e32cc76dc4139269b1bc497b13d4 100644 (file)
@@ -63,10 +63,10 @@ static inline void clear_target(struct target *dest)
        dest->ptr.v = NULL;
 }
 
-static inline void set_target_client(struct target *dest)
+static inline void set_target_client(struct target *dest, struct listener *l)
 {
        dest->type = TARG_TYPE_CLIENT;
-       dest->ptr.v = NULL;
+       dest->ptr.l = l;
 }
 
 static inline void set_target_server(struct target *dest, struct server *s)
@@ -111,6 +111,13 @@ static inline struct server *target_srv(struct target *t)
        return t->ptr.s;
 }
 
+static inline struct listener *target_client(struct target *t)
+{
+       if (!t || t->type != TARG_TYPE_CLIENT)
+               return NULL;
+       return t->ptr.l;
+}
+
 static inline void stream_interface_prepare(struct stream_interface *si, const struct sock_ops *ops)
 {
        si->conn.data = ops;
index 8e9e64b1182d9678df0bae511883c5fb105674be..8218eda94b5d8bf4cbee8c8f775c1a4245a5915c 100644 (file)
@@ -122,6 +122,7 @@ struct target {
                struct server *s;     /* when type is TARG_TYPE_SERVER */
                struct si_applet *a;  /* when type is TARG_TYPE_APPLET */
                struct task *t;       /* when type is TARG_TYPE_TASK */
+               struct listener *l;   /* when type is TARG_TYPE_CLIENT */
        } ptr;
 };
 
index c615b3be0fadeef2ca1241b77f1aad9d24b6fd3b..0ab2e5221a30d4799cb99c0b160576e246c6d30d 100644 (file)
@@ -1157,7 +1157,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[0].conn.ctrl = NULL;
        s->si[0].release = NULL;
        s->si[0].send_proxy_ofs = 0;
-       set_target_client(&s->si[0].target);
+       set_target_client(&s->si[0].target, l);
        s->si[0].exp = TICK_ETERNITY;
        s->si[0].flags = SI_FL_NONE;
        if (s->fe->options2 & PR_O2_INDEPSTR)
index 7bc2248d1b54132009d68c8c5cb9505a8b008fd7..fcd113e437a62de66985ecc0e13222e751abb2cb 100644 (file)
@@ -169,7 +169,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
        s->si[0].conn.ctrl = l->proto;
        s->si[0].release   = NULL;
        s->si[0].send_proxy_ofs = 0;
-       set_target_client(&s->si[0].target);
+       set_target_client(&s->si[0].target, l);
        s->si[0].exp       = TICK_ETERNITY;
        s->si[0].flags     = SI_FL_NONE;