From 40606ab97673fb8dc78b7313faebcda5a2ede4da Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 3 Apr 2015 18:08:29 +0200 Subject: [PATCH] MINOR: session: add a pointer to the session's origin A session's origin is the entity that was responsible for creating the session. It can be an applet or a connection for now. --- include/types/session.h | 1 + src/hlua.c | 2 ++ src/peers.c | 1 + src/stream.c | 1 + 4 files changed, 5 insertions(+) diff --git a/include/types/session.h b/include/types/session.h index 8902065b1..6f26ca994 100644 --- a/include/types/session.h +++ b/include/types/session.h @@ -38,6 +38,7 @@ struct session { struct proxy *fe; /* the proxy this session depends on for the client side */ struct listener *listener; /* the listener by which the request arrived */ + enum obj_type *origin; /* the connection / applet which initiated this session */ }; #endif /* _TYPES_SESSION_H */ diff --git a/src/hlua.c b/src/hlua.c index 293405444..363c09b28 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2197,6 +2197,8 @@ __LJMP static int hlua_socket_new(lua_State *L) goto out_fail_conn1; appctx->ctx.hlua.socket = socket; appctx->ctx.hlua.connected = 0; + socket->s->sess->origin = &appctx->obj_type; + LIST_INIT(&appctx->ctx.hlua.wake_on_write); LIST_INIT(&appctx->ctx.hlua.wake_on_read); diff --git a/src/peers.c b/src/peers.c index df6d47a1c..c27fad048 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1169,6 +1169,7 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session goto out_fail_conn1; appctx->st0 = PEER_SESS_ST_CONNECT; appctx->ctx.peers.ptr = (void *)ps; + s->sess->origin = &appctx->obj_type; si_reset(&s->si[1]); diff --git a/src/stream.c b/src/stream.c index 132e425e0..357e5615a 100644 --- a/src/stream.c +++ b/src/stream.c @@ -123,6 +123,7 @@ int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) s->sess->listener = l; s->sess->fe = p; + s->sess->origin = &cli_conn->obj_type; s->si[0].flags = SI_FL_NONE; s->si[1].flags = SI_FL_ISBACK;