]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: pass the pointer to the origin explicitly to stream_new()
authorWilly Tarreau <w@1wt.eu>
Wed, 8 Apr 2015 16:26:29 +0000 (18:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 8 Apr 2015 16:26:29 +0000 (18:26 +0200)
We don't pass sess->origin anymore but the pointer to the previous step. Now
it should be much easier to chain elements together once applets are moved out
of streams. Indeed, the session is only used for configuration and not for the
dynamic chaining anymore.

include/proto/stream.h
src/hlua.c
src/peers.c
src/session.c
src/stream.c

index 820cf47472206c8a287104961c24654435f23bbf..d4f82136bdd2215aa5e4e5e3514b797a784feaa3 100644 (file)
@@ -36,7 +36,7 @@ extern struct list buffer_wq;
 
 extern struct data_cb sess_conn_cb;
 
-struct stream *stream_new(struct session *sess, struct task *t);
+struct stream *stream_new(struct session *sess, struct task *t, enum obj_type *origin);
 
 /* perform minimal intializations, report 0 in case of error, 1 if OK. */
 int init_stream();
index 1beafeb017f0ca47f5bc6410767c8b30a9ad7cc3..702ba4093b8652e7e2ca57c56e2c3823257a4967 100644 (file)
@@ -2197,7 +2197,7 @@ __LJMP static int hlua_socket_new(lua_State *L)
        }
        task->nice = 0;
 
-       strm = stream_new(sess, task);
+       strm = stream_new(sess, task, &appctx->obj_type);
        if (!strm) {
                hlua_pusherror(L, "socket: out of memory");
                goto out_fail_stream;
index 084a97b8d98162543445947958088a469495e6f6..0676120825e3cf87726bea1c2344c8cf4cc2799d 100644 (file)
@@ -1140,7 +1140,7 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
        }
        t->nice = l->nice;
 
-       if ((s = stream_new(sess, t)) == NULL) {
+       if ((s = stream_new(sess, t, &appctx->obj_type)) == NULL) {
                Alert("Failed to initialize stream in peer_session_create().\n");
                goto out_free_task;
        }
index 714d15ccf84eff4ffe97c4ffc6d9661de0246ba6..7189fbeebc82d627d517c24fbe780f737cc5ef12 100644 (file)
@@ -259,7 +259,7 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
                cli_conn->flags |= CO_FL_XPRT_TRACKED;
 
        session_count_new(sess);
-       strm = stream_new(sess, t);
+       strm = stream_new(sess, t, &cli_conn->obj_type);
        if (!strm)
                goto out_free_task;
 
@@ -424,7 +424,7 @@ static int conn_complete_session(struct connection *conn)
 
        session_count_new(sess);
        task->process = sess->listener->handler;
-       strm = stream_new(sess, task);
+       strm = stream_new(sess, task, &conn->obj_type);
        if (!strm)
                goto fail;
 
index ea24f9f427cdb04a502530ebeae7b083e04484f5..e9a4b0d5b9176d1d97f6b66f889f68d7450ff4bb 100644 (file)
@@ -57,18 +57,18 @@ struct list streams;
 struct list buffer_wq = LIST_HEAD_INIT(buffer_wq);
 
 /* This function is called from the session handler which detects the end of
- * handshake, in order to complete initialization of a valid stream. It must
- * be called with an embryonic session. It returns the pointer to the newly
- * created stream, or NULL in case of fatal error. For now the client-side
- * end point is taken from the session's origin, which must be valid.
- * The task's context is set to the new stream, and its function is set to
- * process_stream(). Target and analysers are null.
+ * handshake, in order to complete initialization of a valid stream. It must be
+ * called with a session (which may be embryonic). It returns the pointer to
+ * the newly created stream, or NULL in case of fatal error. The client-facing
+ * end point is assigned to <origin>, which must be valid. The task's context
+ * is set to the new stream, and its function is set to process_stream().
+ * Target and analysers are null.
  */
-struct stream *stream_new(struct session *sess, struct task *t)
+struct stream *stream_new(struct session *sess, struct task *t, enum obj_type *origin)
 {
        struct stream *s;
-       struct connection *conn = objt_conn(sess->origin);
-       struct appctx *appctx   = objt_appctx(sess->origin);
+       struct connection *conn = objt_conn(origin);
+       struct appctx *appctx   = objt_appctx(origin);
 
        if (unlikely((s = pool_alloc2(pool2_stream)) == NULL))
                return s;