CLEANUP: applet: remove the unneeded appctx->owner

This one is the pointer to the conn_stream which is always in the
endpoint that is always present in the appctx, thus it's not needed.
This patch removes it and replaces it with appctx_cs() instead. A
few occurences that were using __cs_strm(appctx->owner) were moved
directly to appctx_strm() which does the equivalent.
diff --git a/src/activity.c b/src/activity.c
index 022b6b3..2638022 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -621,7 +621,7 @@
 	unsigned long long tot_alloc_calls, tot_free_calls;
 	unsigned long long tot_alloc_bytes, tot_free_bytes;
 #endif
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct buffer *name_buffer = get_trash_chunk();
 	const char *str;
 	int max_lines;
@@ -849,7 +849,7 @@
 static int cli_io_handler_show_tasks(struct appctx *appctx)
 {
 	struct sched_activity tmp_activity[256] __attribute__((aligned(64)));
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct buffer *name_buffer = get_trash_chunk();
 	struct sched_activity *entry;
 	const struct tasklet *tl;
diff --git a/src/applet.c b/src/applet.c
index 35fd8e1..9e15c7e 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -117,7 +117,7 @@
 int appctx_buf_available(void *arg)
 {
 	struct appctx *appctx = arg;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	/* allocation requested ? */
 	if (!(appctx->endp->flags & CS_EP_RXBLK_BUFF))
@@ -143,7 +143,7 @@
 struct task *task_run_applet(struct task *t, void *context, unsigned int state)
 {
 	struct appctx *app = context;
-	struct conn_stream *cs = app->owner;
+	struct conn_stream *cs = appctx_cs(app);
 	unsigned int rate;
 	size_t count;
 
diff --git a/src/cache.c b/src/cache.c
index 2e5c5a4..dfe8863 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -1293,7 +1293,8 @@
 	unsigned int max, total;
 	uint32_t blksz;
 
-	max = htx_get_max_blksz(htx, channel_htx_recv_max(cs_ic(appctx->owner), htx));
+	max = htx_get_max_blksz(htx,
+				channel_htx_recv_max(cs_ic(appctx_cs(appctx)), htx));
 	if (!max)
 		return 0;
 	blksz = ((type == HTX_BLK_HDR || type == HTX_BLK_TLR)
@@ -1336,7 +1337,8 @@
 	unsigned int max, total, rem_data;
 	uint32_t blksz;
 
-	max = htx_get_max_blksz(htx, channel_htx_recv_max(cs_ic(appctx->owner), htx));
+	max = htx_get_max_blksz(htx,
+				channel_htx_recv_max(cs_ic(appctx_cs(appctx)), htx));
 	if (!max)
 		return 0;
 
@@ -1453,7 +1455,7 @@
 	struct cache_appctx *ctx = appctx->svcctx;
 	struct cache_entry *cache_ptr = ctx->entry;
 	struct shared_block *first = block_ptr(cache_ptr);
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct channel *req = cs_oc(cs);
 	struct channel *res = cs_ic(cs);
 	struct htx *req_htx, *res_htx;
@@ -2598,7 +2600,7 @@
 {
 	struct show_cache_ctx *ctx = appctx->svcctx;
 	struct cache* cache = ctx->cache;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	list_for_each_entry_from(cache, &caches, list) {
 		struct eb32_node *node = NULL;
diff --git a/src/cli.c b/src/cli.c
index 30d24b8..b533938 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -722,7 +722,7 @@
 {
 	if (appctx->cli_severity_output)
 		return appctx->cli_severity_output;
-	return strm_li(__cs_strm(appctx->owner))->bind_conf->severity_output;
+	return strm_li(appctx_strm(appctx))->bind_conf->severity_output;
 }
 
 /* Processes the CLI interpreter on the stats socket. This function is called
@@ -897,7 +897,7 @@
  */
 static void cli_io_handler(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct channel *req = cs_oc(cs);
 	struct channel *res = cs_ic(cs);
 	struct bind_conf *bind_conf = strm_li(__cs_strm(cs))->bind_conf;
@@ -1226,7 +1226,7 @@
 static int cli_io_handler_show_env(struct appctx *appctx)
 {
 	struct show_env_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	char **var = ctx->var;
 
 	if (unlikely(cs_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
@@ -1262,7 +1262,7 @@
  */
 static int cli_io_handler_show_fd(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct show_fd_ctx *fdctx = appctx->svcctx;
 	int fd = fdctx->fd;
 	int ret = 1;
@@ -1462,7 +1462,7 @@
  */
 static int cli_io_handler_show_activity(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int thr;
 
 	if (unlikely(cs_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
@@ -1567,7 +1567,7 @@
 {
 	struct show_sock_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 	struct bind_conf *bind_conf = ctx->bind_conf;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	if (!global.cli_fe)
 		goto done;
@@ -1693,7 +1693,7 @@
 /* parse a "set timeout" CLI request. It always returns 1. */
 static int cli_parse_set_timeout(char **args, char *payload, struct appctx *appctx, void *private)
 {
-	struct stream *s = __cs_strm(appctx->owner);
+	struct stream *s = appctx_strm(appctx);
 
 	if (strcmp(args[2], "cli") == 0) {
 		unsigned timeout;
@@ -1976,7 +1976,7 @@
 	char *cmsgbuf = NULL;
 	unsigned char *tmpbuf = NULL;
 	struct cmsghdr *cmsg;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct connection *remote = cs_conn(cs_opposite(cs));
 	struct msghdr msghdr;
diff --git a/src/conn_stream.c b/src/conn_stream.c
index ff8704f..c13a2a1 100644
--- a/src/conn_stream.c
+++ b/src/conn_stream.c
@@ -179,12 +179,10 @@
 struct conn_stream *cs_new_from_applet(struct cs_endpoint *endp, struct session *sess, struct buffer *input)
 {
 	struct conn_stream *cs;
-	struct appctx *appctx = endp->ctx;
 
 	cs = cs_new(endp);
 	if (unlikely(!cs))
 		return NULL;
-	appctx->owner = cs;
 	if (unlikely(!stream_new(sess, cs, input))) {
 		pool_free(pool_head_connstream, cs);
 		cs = NULL;
@@ -300,13 +298,10 @@
  */
 static void cs_attach_applet(struct conn_stream *cs, void *target, void *ctx)
 {
-	struct appctx *appctx = target;
-
 	cs->endp->target = target;
 	cs->endp->ctx = ctx;
 	cs->endp->flags |= CS_EP_T_APPLET;
 	cs->endp->flags &= ~CS_EP_DETACHED;
-	appctx->owner = cs;
 	if (cs_strm(cs)) {
 		cs->ops = &cs_app_applet_ops;
 		cs->data_cb = &cs_data_applet_cb;
@@ -505,7 +500,6 @@
 	if (!appctx)
 		return NULL;
 	cs_attach_applet(cs, appctx, appctx);
-	appctx->owner = cs;
 	appctx->t->nice = __cs_strm(cs)->task->nice;
 	cs_cant_get(cs);
 	appctx_wakeup(appctx);
diff --git a/src/debug.c b/src/debug.c
index db7dcbe..8583111 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -251,7 +251,7 @@
 	if (task->process == process_stream && task->context)
 		s = (struct stream *)task->context;
 	else if (task->process == task_run_applet && task->context)
-		s = cs_strm(((struct appctx *)task->context)->owner);
+		s = cs_strm(appctx_cs((struct appctx *)task->context));
 	else if (task->process == cs_conn_io_cb && task->context)
 		s = cs_strm(((struct conn_stream *)task->context));
 
@@ -290,7 +290,7 @@
  */
 static int cli_io_handler_show_threads(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int thr;
 
 	if (unlikely(cs_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
@@ -676,7 +676,7 @@
  */
 static int debug_parse_cli_stream(char **args, char *payload, struct appctx *appctx, void *private)
 {
-	struct stream *s = __cs_strm(appctx->owner);
+	struct stream *s = appctx_strm(appctx);
 	int arg;
 	void *ptr;
 	int size;
@@ -1044,7 +1044,7 @@
 static int debug_iohandler_fd(struct appctx *appctx)
 {
 	struct dev_fd_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct sockaddr_storage sa;
 	struct stat statbuf;
 	socklen_t salen, vlen;
@@ -1239,7 +1239,7 @@
 static int debug_iohandler_memstats(struct appctx *appctx)
 {
 	struct dev_mem_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct mem_stats *ptr = ctx->start;
 	int ret = 1;
 
diff --git a/src/dns.c b/src/dns.c
index 712cc56..35ff61a 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -438,7 +438,7 @@
  */
 static void dns_session_io_handler(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct dns_session *ds = appctx->svcctx;
 	struct ring *ring = &ds->ring;
 	struct buffer *buf = &ring->buf;
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index f032e83..59db428 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -1137,7 +1137,7 @@
 static int
 spoe_send_frame(struct appctx *appctx, char *buf, size_t framesz)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int      ret;
 	uint32_t netint;
 
@@ -1163,7 +1163,7 @@
 static int
 spoe_recv_frame(struct appctx *appctx, char *buf, size_t framesz)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int      ret;
 	uint32_t netint;
 
@@ -1192,8 +1192,8 @@
 static int
 spoe_wakeup_appctx(struct appctx *appctx)
 {
-	cs_want_get(appctx->owner);
-	cs_rx_endp_more(appctx->owner);
+	cs_want_get(appctx_cs(appctx));
+	cs_rx_endp_more(appctx_cs(appctx));
 	appctx_wakeup(appctx);
 	return 1;
 }
@@ -1219,7 +1219,7 @@
 static void
 spoe_release_appctx(struct appctx *appctx)
 {
-	struct conn_stream  *cs          = appctx->owner;
+	struct conn_stream  *cs          = appctx_cs(appctx);
 	struct spoe_appctx  *spoe_appctx = SPOE_APPCTX(appctx);
 	struct spoe_agent   *agent;
 	struct spoe_context *ctx, *back;
@@ -1339,7 +1339,7 @@
 static int
 spoe_handle_connect_appctx(struct appctx *appctx)
 {
-	struct conn_stream *cs    = appctx->owner;
+	struct conn_stream *cs    = appctx_cs(appctx);
 	struct spoe_agent  *agent = SPOE_APPCTX(appctx)->agent;
 	char *frame, *buf;
 	int   ret;
@@ -1405,7 +1405,7 @@
 static int
 spoe_handle_connecting_appctx(struct appctx *appctx)
 {
-	struct conn_stream *cs     = appctx->owner;
+	struct conn_stream *cs     = appctx_cs(appctx);
 	struct spoe_agent  *agent  = SPOE_APPCTX(appctx)->agent;
 	char  *frame;
 	int    ret;
@@ -1650,7 +1650,7 @@
 
 	/* Do not forget to remove processed frame from the output buffer */
 	if (trash.data)
-		co_skip(cs_oc(appctx->owner), trash.data);
+		co_skip(cs_oc(appctx_cs(appctx)), trash.data);
   end:
 	return ret;
 }
@@ -1658,7 +1658,7 @@
 static int
 spoe_handle_processing_appctx(struct appctx *appctx)
 {
-	struct conn_stream      *cs    = appctx->owner;
+	struct conn_stream      *cs    = appctx_cs(appctx);
 	struct server           *srv   = objt_server(__cs_strm(cs)->target);
 	struct spoe_agent       *agent = SPOE_APPCTX(appctx)->agent;
 	int ret, skip_sending = 0, skip_receiving = 0, active_s = 0, active_r = 0, close_asap = 0;
@@ -1781,7 +1781,7 @@
 static int
 spoe_handle_disconnect_appctx(struct appctx *appctx)
 {
-	struct conn_stream *cs    = appctx->owner;
+	struct conn_stream *cs    = appctx_cs(appctx);
 	struct spoe_agent  *agent = SPOE_APPCTX(appctx)->agent;
 	char *frame, *buf;
 	int   ret;
@@ -1834,7 +1834,7 @@
 static int
 spoe_handle_disconnecting_appctx(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	char  *frame;
 	int    ret;
 
@@ -1899,7 +1899,7 @@
 static void
 spoe_handle_appctx(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct spoe_agent  *agent;
 
 	if (SPOE_APPCTX(appctx) == NULL)
diff --git a/src/hlua.c b/src/hlua.c
index 8d6fc35..91a9f7c 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -1943,7 +1943,7 @@
 static void hlua_socket_handler(struct appctx *appctx)
 {
 	struct hlua_csk_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	if (ctx->die) {
 		cs_shutw(cs);
@@ -2143,7 +2143,7 @@
 
 	csk_ctx = container_of(peer, struct hlua_csk_ctx, xref);
 	appctx = csk_ctx->appctx;
-	s = __cs_strm(appctx->owner);
+	s = appctx_strm(appctx);
 
 	oc = &s->res;
 	if (wanted == HLSR_READ_LINE) {
@@ -2384,7 +2384,7 @@
 
 	csk_ctx = container_of(peer, struct hlua_csk_ctx, xref);
 	appctx = csk_ctx->appctx;
-	cs = appctx->owner;
+	cs = appctx_cs(appctx);
 	s = __cs_strm(cs);
 
 	/* Check for connection close. */
@@ -2618,7 +2618,7 @@
 	}
 
 	appctx = container_of(peer, struct hlua_csk_ctx, xref)->appctx;
-	cs = appctx->owner;
+	cs = appctx_cs(appctx);
 	dst = cs_dst(cs_opposite(cs));
 	if (!dst) {
 		xref_unlock(&socket->xref, peer);
@@ -2659,7 +2659,7 @@
 	}
 
 	appctx = container_of(peer, struct hlua_csk_ctx, xref)->appctx;
-	s = __cs_strm(appctx->owner);
+	s = appctx_strm(appctx);
 
 	conn = cs_conn(s->csb);
 	if (!conn || !conn_get_src(conn)) {
@@ -2711,7 +2711,7 @@
 
 	csk_ctx = container_of(peer, struct hlua_csk_ctx, xref);
 	appctx = csk_ctx->appctx;
-	s = __cs_strm(appctx->owner);
+	s = appctx_strm(appctx);
 
 	/* Check if we run on the same thread than the xreator thread.
 	 * We cannot access to the socket if the thread is different.
@@ -2824,7 +2824,7 @@
 
 	csk_ctx = container_of(peer, struct hlua_csk_ctx, xref);
 	appctx = csk_ctx->appctx;
-	cs = appctx->owner;
+	cs = appctx_cs(appctx);
 	s = __cs_strm(cs);
 
 	if (!sockaddr_alloc(&cs_opposite(cs)->dst, addr, sizeof(*addr))) {
@@ -2865,7 +2865,6 @@
 {
 	struct hlua_socket *socket;
 	struct xref *peer;
-	struct appctx *appctx;
 	struct stream *s;
 
 	MAY_LJMP(check_args(L, 3, "connect_ssl"));
@@ -2878,8 +2877,7 @@
 		return 1;
 	}
 
-	appctx = container_of(peer, struct hlua_csk_ctx, xref)->appctx;
-	s = __cs_strm(appctx->owner);
+	s = appctx_strm(container_of(peer, struct hlua_csk_ctx, xref)->appctx);
 
 	s->target = &socket_ssl->obj_type;
 	xref_unlock(&socket->xref, peer);
@@ -2898,7 +2896,6 @@
 	int tmout;
 	double dtmout;
 	struct xref *peer;
-	struct appctx *appctx;
 	struct stream *s;
 
 	MAY_LJMP(check_args(L, 2, "settimeout"));
@@ -2933,8 +2930,7 @@
 		return 0;
 	}
 
-	appctx = container_of(peer, struct hlua_csk_ctx, xref)->appctx;
-	s = __cs_strm(appctx->owner);
+	s = appctx_strm(container_of(peer, struct hlua_csk_ctx, xref)->appctx);
 
 	s->sess->fe->timeout.connect = tmout;
 	s->req.rto = tmout;
@@ -4310,7 +4306,7 @@
 static int hlua_applet_tcp_new(lua_State *L, struct appctx *ctx)
 {
 	struct hlua_appctx *luactx;
-	struct stream *s = __cs_strm(ctx->owner);
+	struct stream *s = appctx_strm(ctx);
 	struct proxy *p;
 
 	ALREADY_CHECKED(s);
@@ -4493,7 +4489,7 @@
 __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KContext ctx)
 {
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	int ret;
 	const char *blk1;
 	size_t len1;
@@ -4547,7 +4543,7 @@
 __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KContext ctx)
 {
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	size_t len = MAY_LJMP(luaL_checkinteger(L, 2));
 	int ret;
 	const char *blk1;
@@ -4655,7 +4651,7 @@
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
 	const char *str = MAY_LJMP(luaL_checklstring(L, 2, &len));
 	int l = MAY_LJMP(luaL_checkinteger(L, 3));
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	struct channel *chn = cs_ic(cs);
 	int max;
 
@@ -4721,7 +4717,7 @@
 	struct hlua_http_ctx *http_ctx = ctx->svcctx;
 	struct hlua_appctx *luactx;
 	struct hlua_txn htxn;
-	struct stream *s = __cs_strm(ctx->owner);
+	struct stream *s = appctx_strm(ctx);
 	struct proxy *px = s->be;
 	struct htx *htx;
 	struct htx_blk *blk;
@@ -4982,7 +4978,7 @@
 __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_KContext ctx)
 {
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	struct channel *req = cs_oc(cs);
 	struct htx *htx;
 	struct htx_blk *blk;
@@ -5077,7 +5073,7 @@
 __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KContext ctx)
 {
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	struct channel *req = cs_oc(cs);
 	struct htx *htx;
 	struct htx_blk *blk;
@@ -5186,7 +5182,7 @@
 __LJMP static int hlua_applet_http_send_yield(lua_State *L, int status, lua_KContext ctx)
 {
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	struct channel *res = cs_ic(cs);
 	struct htx *htx = htx_from_buf(&res->buf);
 	const char *data;
@@ -5323,7 +5319,7 @@
 {
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
 	struct hlua_http_ctx *http_ctx = luactx->appctx->svcctx;
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	struct channel *res = cs_ic(cs);
 	struct htx *htx;
 	struct htx_sl *sl;
@@ -5520,7 +5516,7 @@
 __LJMP static int hlua_applet_http_start_response_yield(lua_State *L, int status, lua_KContext ctx)
 {
 	struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
-	struct conn_stream *cs = luactx->appctx->owner;
+	struct conn_stream *cs = appctx_cs(luactx->appctx);
 	struct channel *res = cs_ic(cs);
 
 	if (co_data(res)) {
@@ -9230,7 +9226,7 @@
 static int hlua_applet_tcp_init(struct appctx *ctx)
 {
 	struct hlua_tcp_ctx *tcp_ctx = applet_reserve_svcctx(ctx, sizeof(*tcp_ctx));
-	struct conn_stream *cs = ctx->owner;
+	struct conn_stream *cs = appctx_cs(ctx);
 	struct stream *strm = __cs_strm(cs);
 	struct hlua *hlua;
 	struct task *task;
@@ -9328,7 +9324,7 @@
 void hlua_applet_tcp_fct(struct appctx *ctx)
 {
 	struct hlua_tcp_ctx *tcp_ctx = ctx->svcctx;
-	struct conn_stream *cs = ctx->owner;
+	struct conn_stream *cs = appctx_cs(ctx);
 	struct stream *strm = __cs_strm(cs);
 	struct channel *res = cs_ic(cs);
 	struct act_rule *rule = ctx->rule;
@@ -9422,7 +9418,7 @@
 static int hlua_applet_http_init(struct appctx *ctx)
 {
 	struct hlua_http_ctx *http_ctx = applet_reserve_svcctx(ctx, sizeof(*http_ctx));
-	struct conn_stream *cs = ctx->owner;
+	struct conn_stream *cs = appctx_cs(ctx);
 	struct stream *strm = __cs_strm(cs);
 	struct http_txn *txn;
 	struct hlua *hlua;
@@ -9525,7 +9521,7 @@
 void hlua_applet_http_fct(struct appctx *ctx)
 {
 	struct hlua_http_ctx *http_ctx = ctx->svcctx;
-	struct conn_stream *cs = ctx->owner;
+	struct conn_stream *cs = appctx_cs(ctx);
 	struct stream *strm = __cs_strm(cs);
 	struct channel *req = cs_oc(cs);
 	struct channel *res = cs_ic(cs);
@@ -10162,7 +10158,7 @@
 	struct hlua_function *fcn;
 
 	hlua = ctx->hlua;
-	cs = appctx->owner;
+	cs = appctx_cs(appctx);
 	fcn = ctx->fcn;
 
 	/* If the stream is disconnect or closed, ldo nothing. */
diff --git a/src/http_client.c b/src/http_client.c
index bff7057..1efb484 100644
--- a/src/http_client.c
+++ b/src/http_client.c
@@ -195,7 +195,7 @@
 static int hc_cli_io_handler(struct appctx *appctx)
 {
 	struct hcli_svc_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct buffer *trash = alloc_trash_chunk();
 	struct httpclient *hc = ctx->hc;
 	struct http_hdr *hdrs, *hdr;
@@ -739,7 +739,7 @@
 static void httpclient_applet_io_handler(struct appctx *appctx)
 {
 	struct httpclient *hc = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct channel *req = &s->req;
 	struct channel *res = &s->res;
diff --git a/src/log.c b/src/log.c
index 522c2f6..be98982 100644
--- a/src/log.c
+++ b/src/log.c
@@ -3559,7 +3559,7 @@
 static void syslog_io_handler(struct appctx *appctx)
 {
 	static THREAD_LOCAL struct ist metadata[LOG_META_FIELDS];
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct proxy *frontend = strm_fe(s);
 	struct listener *l = strm_li(s);
diff --git a/src/map.c b/src/map.c
index dea9bcd..89bbd9e 100644
--- a/src/map.c
+++ b/src/map.c
@@ -345,7 +345,7 @@
 static int cli_io_handler_pat_list(struct appctx *appctx)
 {
 	struct show_map_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct pat_ref_elt *elt;
 
 	if (unlikely(cs_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
@@ -417,7 +417,7 @@
 static int cli_io_handler_pats_list(struct appctx *appctx)
 {
 	struct show_map_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	switch (ctx->state) {
 	case STATE_INIT:
@@ -480,7 +480,7 @@
 static int cli_io_handler_map_lookup(struct appctx *appctx)
 {
 	struct show_map_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct sample sample;
 	struct pattern *pat;
 	int match_method;
@@ -1030,7 +1030,7 @@
 
 	if (!finished) {
 		/* let's come back later */
-		cs_rx_endp_more(appctx->owner);
+		cs_rx_endp_more(appctx_cs(appctx));
 		return 0;
 	}
 	return 1;
diff --git a/src/mworker.c b/src/mworker.c
index 1ee93fb..24fde3c 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -509,7 +509,7 @@
 /*  Displays workers and processes  */
 static int cli_io_handler_show_proc(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct mworker_proc *child;
 	int old = 0;
 	int up = now.tv_sec - proc_self->timestamp;
diff --git a/src/peers.c b/src/peers.c
index 0d91995..f521b55 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -444,7 +444,7 @@
 			struct peers *peers = NULL;
 
 			if (peer->appctx) {
-				struct stream *s = __cs_strm(peer->appctx->owner);
+				struct stream *s = appctx_strm(peer->appctx);
 
 				peers = strm_fe(s)->parent;
 			}
@@ -1043,7 +1043,7 @@
 	if (!peer->appctx)
 		return;
 
-	s = __cs_strm(peer->appctx->owner);
+	s = appctx_strm(peer->appctx);
 
 	peers = strm_fe(s)->parent;
 	if (!peers)
@@ -1136,7 +1136,7 @@
  */
 static inline int peer_getline(struct appctx  *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int n;
 
 	n = co_getline(cs_oc(cs), trash.area, trash.size);
@@ -1170,7 +1170,7 @@
                                 struct peer_prep_params *params)
 {
 	int ret, msglen;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	msglen = peer_prepare_msg(trash.area, trash.size, params);
 	if (!msglen) {
@@ -1650,7 +1650,7 @@
 static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt, int exp,
                                 char **msg_cur, char *msg_end, int msg_len, int totl)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct shared_table *st = p->remote_table;
 	struct stksess *ts, *newts;
 	uint32_t update;
@@ -2102,7 +2102,7 @@
 static inline int peer_treat_definemsg(struct appctx *appctx, struct peer *p,
                                       char **msg_cur, char *msg_end, int totl)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int table_id_len;
 	struct shared_table *st;
 	int table_type;
@@ -2301,7 +2301,7 @@
                                 uint32_t *msg_len, int *totl)
 {
 	int reql;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	char *cur;
 
 	reql = co_getblk(cs_oc(cs), msg_head, 2 * sizeof(char), *totl);
@@ -2373,7 +2373,7 @@
 static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *peer, unsigned char *msg_head,
                                          char **msg_cur, char *msg_end, int msg_len, int totl)
 {
-	struct stream *s = __cs_strm(appctx->owner);
+	struct stream *s = appctx_strm(appctx);
 	struct peers *peers = strm_fe(s)->parent;
 
 	if (msg_head[0] == PEER_MSG_CLASS_CONTROL) {
@@ -2660,7 +2660,7 @@
 	char *p;
 	int reql;
 	struct peer *peer;
-	struct stream *s = __cs_strm(appctx->owner);
+	struct stream *s = appctx_strm(appctx);
 	struct peers *peers = strm_fe(s)->parent;
 
 	reql = peer_getline(appctx);
@@ -2820,7 +2820,7 @@
  */
 static void peer_io_handler(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct peers *curpeers = strm_fe(s)->parent;
 	struct peer *curpeer = NULL;
@@ -3827,7 +3827,7 @@
 	chunk_appendf(&trash, " appctx:%p st0=%d st1=%d task_calls=%u", appctx, appctx->st0, appctx->st1,
 	                                                                appctx->t ? appctx->t->calls : 0);
 
-	peer_cs = peer->appctx->owner;
+	peer_cs = appctx_cs(peer->appctx);
 	peer_s = __cs_strm(peer_cs);
 
 	chunk_appendf(&trash, " state=%s", cs_state_str(cs_opposite(peer_cs)->state));
@@ -3962,7 +3962,7 @@
 					chunk_appendf(&trash, "\n");
 				else
 					first_peers = 0;
-				if (!peers_dump_head(&trash, appctx->owner, ctx->peers))
+				if (!peers_dump_head(&trash, appctx_cs(appctx), ctx->peers))
 					goto out;
 
 				ctx->peer = ctx->peers->remote;
@@ -3980,7 +3980,7 @@
 					ctx->state = STATE_DONE;
 			}
 			else {
-				if (!peers_dump_peer(&trash, appctx->owner, ctx->peer, ctx->flags))
+				if (!peers_dump_peer(&trash, appctx_cs(appctx), ctx->peer, ctx->flags))
 					goto out;
 
 				ctx->peer = ctx->peer->next;
diff --git a/src/pool.c b/src/pool.c
index 8352531..2b4754e 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -1011,7 +1011,7 @@
  */
 static int cli_io_handler_dump_pools(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	dump_pools_to_trash();
 	if (ci_putchk(cs_ic(cs), &trash) == -1) {
diff --git a/src/proxy.c b/src/proxy.c
index 0badc11..9c856f3 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -2787,7 +2787,7 @@
 static int cli_io_handler_servers_state(struct appctx *appctx)
 {
 	struct show_srv_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct proxy *curproxy;
 
 	if (ctx->state == SHOW_SRV_HEAD) {
@@ -2828,7 +2828,7 @@
  */
 static int cli_io_handler_show_backend(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct proxy *curproxy;
 
 	chunk_reset(&trash);
@@ -3144,7 +3144,7 @@
 static int cli_io_handler_show_errors(struct appctx *appctx)
 {
 	struct show_errors_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	extern const char *monthname[12];
 
 	if (unlikely(cs_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
diff --git a/src/resolvers.c b/src/resolvers.c
index e58fa59..aba2d24 100644
--- a/src/resolvers.c
+++ b/src/resolvers.c
@@ -2760,7 +2760,7 @@
 static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx)
 {
 	struct show_resolvers_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct resolvers    *resolvers = ctx->resolvers;
 	struct dns_nameserver   *ns;
 
diff --git a/src/ring.c b/src/ring.c
index d2c1c4a..33eb62a 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -290,7 +290,7 @@
 int cli_io_handler_show_ring(struct appctx *appctx)
 {
 	struct show_ring_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct ring *ring = ctx->ring;
 	struct buffer *buf = &ring->buf;
 	size_t ofs = ctx->ofs;
diff --git a/src/server.c b/src/server.c
index a0da6e6..fd24ef8 100644
--- a/src/server.c
+++ b/src/server.c
@@ -4315,7 +4315,7 @@
 
 static int cli_parse_get_weight(char **args, char *payload, struct appctx *appctx, void *private)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct proxy *px;
 	struct server *sv;
 	char *line;
diff --git a/src/sink.c b/src/sink.c
index 9f0bfb8..3dc4a4d 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -299,7 +299,7 @@
  */
 static void sink_forward_io_handler(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct sink *sink = strm_fe(s)->parent;
 	struct sink_forward_target *sft = appctx->svcctx;
@@ -439,7 +439,7 @@
  */
 static void sink_forward_oc_io_handler(struct appctx *appctx)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct sink *sink = strm_fe(s)->parent;
 	struct sink_forward_target *sft = appctx->svcctx;
@@ -579,7 +579,7 @@
 
 void __sink_forward_session_deinit(struct sink_forward_target *sft)
 {
-	struct stream *s = __cs_strm(sft->appctx->owner);
+	struct stream *s = appctx_strm(sft->appctx);
 	struct sink *sink;
 
 	sink = strm_fe(s)->parent;
diff --git a/src/ssl_ckch.c b/src/ssl_ckch.c
index 6238c7e..20e2dfc 100644
--- a/src/ssl_ckch.c
+++ b/src/ssl_ckch.c
@@ -1314,7 +1314,7 @@
 	struct show_cert_ctx *ctx = appctx->svcctx;
 	struct buffer *trash = alloc_trash_chunk();
 	struct ebmb_node *node;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct ckch_store *ckchs;
 
 	if (trash == NULL)
@@ -1716,7 +1716,7 @@
 static int cli_io_handler_show_cert_detail(struct appctx *appctx)
 {
 	struct show_cert_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct ckch_store *ckchs = ctx->cur_ckchs;
 	struct buffer *out = alloc_trash_chunk();
 	int retval = 0;
@@ -1767,7 +1767,7 @@
 {
 #if ((defined SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB && !defined OPENSSL_NO_OCSP) && !defined OPENSSL_IS_BORINGSSL)
 	struct show_cert_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct ckch_store *ckchs = ctx->cur_ckchs;
 	struct buffer *out = alloc_trash_chunk();
 	int from_transaction = ctx->transaction;
@@ -2048,7 +2048,7 @@
 static int cli_io_handler_commit_cert(struct appctx *appctx)
 {
 	struct commit_cert_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int y = 0;
 	char *err = NULL;
 	struct ckch_store *old_ckchs, *new_ckchs = NULL;
@@ -2793,7 +2793,7 @@
 static int cli_io_handler_commit_cafile_crlfile(struct appctx *appctx)
 {
 	struct commit_cacrlfile_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	int y = 0;
 	char *err = NULL;
 	struct cafile_entry *old_cafile_entry = NULL, *new_cafile_entry = NULL;
@@ -3025,7 +3025,7 @@
 static int cli_io_handler_show_cafile_detail(struct appctx *appctx)
 {
 	struct show_cafile_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct cafile_entry *cafile_entry = ctx->cur_cafile_entry;
 	struct buffer *out = alloc_trash_chunk();
 	int i = 0;
@@ -3196,7 +3196,7 @@
 	struct show_cafile_ctx *ctx = appctx->svcctx;
 	struct buffer *trash = alloc_trash_chunk();
 	struct ebmb_node *node;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct cafile_entry *cafile_entry;
 
 	if (trash == NULL)
@@ -3712,7 +3712,7 @@
 static int cli_io_handler_show_crlfile_detail(struct appctx *appctx)
 {
 	struct show_crlfile_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct cafile_entry *cafile_entry = ctx->cafile_entry;
 	struct buffer *out = alloc_trash_chunk();
 	int i;
@@ -3847,7 +3847,7 @@
 	struct show_crlfile_ctx *ctx = appctx->svcctx;
 	struct buffer *trash = alloc_trash_chunk();
 	struct ebmb_node *node;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct cafile_entry *cafile_entry;
 
 	if (trash == NULL)
diff --git a/src/ssl_crtlist.c b/src/ssl_crtlist.c
index 56d2bc4..e8f1bc5 100644
--- a/src/ssl_crtlist.c
+++ b/src/ssl_crtlist.c
@@ -913,7 +913,7 @@
 {
 	struct show_crtlist_ctx *ctx = appctx->svcctx;
 	struct buffer *trash = alloc_trash_chunk();
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct ebmb_node *lnode;
 
 	if (trash == NULL)
@@ -945,7 +945,7 @@
 	struct show_crtlist_ctx *ctx = appctx->svcctx;
 	struct buffer *trash = alloc_trash_chunk();
 	struct crtlist *crtlist;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct crtlist_entry *entry;
 
 	if (trash == NULL)
@@ -1071,7 +1071,7 @@
 {
 	struct add_crtlist_ctx *ctx = appctx->svcctx;
 	struct bind_conf_list *bind_conf_node;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct crtlist *crtlist = ctx->crtlist;
 	struct crtlist_entry *entry = ctx->entry;
 	struct ckch_store *store = entry->node.key;
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index e8e0eab..6ffdf4d 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -7224,7 +7224,7 @@
 static int cli_io_handler_tlskeys_files(struct appctx *appctx)
 {
 	struct show_keys_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	switch (ctx->state) {
 	case SHOW_KEYS_INIT:
@@ -7503,7 +7503,7 @@
 	struct buffer *trash = alloc_trash_chunk();
 	struct buffer *tmp = NULL;
 	struct ebmb_node *node;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct certificate_ocsp *ocsp = NULL;
 	BIO *bio = NULL;
 	int write = -1;
@@ -7639,7 +7639,7 @@
 static int cli_io_handler_show_providers(struct appctx *appctx)
 {
 	struct buffer *trash = get_trash_chunk();
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct list provider_names;
 	struct provider_name *name;
 
@@ -7770,7 +7770,7 @@
 {
 	struct buffer *trash = alloc_trash_chunk();
 	struct certificate_ocsp *ocsp = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 
 	if (trash == NULL)
 		return 1;
diff --git a/src/stats.c b/src/stats.c
index aef9bac..49d6ef0 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -4283,7 +4283,7 @@
 static void http_stats_io_handler(struct appctx *appctx)
 {
 	struct show_stat_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct channel *req = cs_oc(cs);
 	struct channel *res = cs_ic(cs);
@@ -4948,7 +4948,7 @@
 	ctx->scope_len = 0;
 	ctx->flags = STAT_SHNODE | STAT_SHDESC;
 
-	if ((strm_li(__cs_strm(appctx->owner))->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER)
+	if ((strm_li(appctx_strm(appctx))->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER)
 		ctx->flags |= STAT_SHLGNDS;
 
 	/* proxy is the default domain */
@@ -5004,7 +5004,7 @@
 
 static int cli_io_handler_dump_info(struct appctx *appctx)
 {
-	return stats_dump_info_to_buffer(appctx->owner);
+	return stats_dump_info_to_buffer(appctx_cs(appctx));
 }
 
 /* This I/O handler runs as an applet embedded in a conn-stream. It is
@@ -5012,12 +5012,12 @@
  */
 static int cli_io_handler_dump_stat(struct appctx *appctx)
 {
-	return stats_dump_stat_to_buffer(appctx->owner, NULL, NULL);
+	return stats_dump_stat_to_buffer(appctx_cs(appctx), NULL, NULL);
 }
 
 static int cli_io_handler_dump_json_schema(struct appctx *appctx)
 {
-	return stats_dump_json_schema_to_buffer(appctx->owner);
+	return stats_dump_json_schema_to_buffer(appctx_cs(appctx));
 }
 
 int stats_allocate_proxy_counters_internal(struct extra_counters **counters,
diff --git a/src/stick_table.c b/src/stick_table.c
index 0e08d7d..9277722 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -4408,7 +4408,7 @@
  */
 static int table_process_entry_per_key(struct appctx *appctx, char **args)
 {
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct show_table_ctx *ctx = appctx->svcctx;
 	struct stktable *t = ctx->target;
 	struct stksess *ts;
@@ -4668,7 +4668,7 @@
 static int cli_io_handler_table(struct appctx *appctx)
 {
 	struct show_table_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct stream *s = __cs_strm(cs);
 	struct ebmb_node *eb;
 	int skip_entry;
diff --git a/src/stream.c b/src/stream.c
index d86dbf3..c700236 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -2818,7 +2818,7 @@
 		if (!appctx)
 			return;
 		ptr = appctx;
-		s = __cs_strm(appctx->owner);
+		s = appctx_strm(appctx);
 		if (!s)
 			return;
 	}
@@ -3524,7 +3524,7 @@
 	/* let's set our own stream's epoch to the current one and increment
 	 * it so that we know which streams were already there before us.
 	 */
-	__cs_strm(appctx->owner)->stream_epoch = _HA_ATOMIC_FETCH_ADD(&stream_epoch, 1);
+	appctx_strm(appctx)->stream_epoch = _HA_ATOMIC_FETCH_ADD(&stream_epoch, 1);
 	return 0;
 }
 
@@ -3536,7 +3536,7 @@
 static int cli_io_handler_dump_sess(struct appctx *appctx)
 {
 	struct show_sess_ctx *ctx = appctx->svcctx;
-	struct conn_stream *cs = appctx->owner;
+	struct conn_stream *cs = appctx_cs(appctx);
 	struct connection *conn;
 
 	thread_isolate();
@@ -3579,7 +3579,7 @@
 		else {
 			/* check if we've found a stream created after issuing the "show sess" */
 			curr_strm = LIST_ELEM(ctx->bref.ref, struct stream *, list);
-			if ((int)(curr_strm->stream_epoch - __cs_strm(appctx->owner)->stream_epoch) > 0)
+			if ((int)(curr_strm->stream_epoch - appctx_strm(appctx)->stream_epoch) > 0)
 				done = 1;
 		}