conn->target = s->target = &s->be->obj_type;
memcpy(&conn->addr.to, &peer->addr, sizeof(conn->addr.to));
s->do_log = NULL;
-
- /* default error reporting function, may be changed by analysers */
- s->srv_error = default_srv_error;
s->uniq_id = 0;
- /* note: this should not happen anymore since there's always at least the switching rules */
- if (!s->req.analysers) {
- channel_auto_connect(&s->req);/* don't wait to establish connection */
- channel_auto_close(&s->req); /* let the producer forward close requests */
- }
-
s->req.rto = s->sess->fe->timeout.client;
s->req.wto = s->be->timeout.server;
s->res.rto = s->be->timeout.server;
struct connection *cli_conn;
struct proxy *p = l->frontend;
struct session *sess;
+ struct stream *strm;
struct task *t;
int ret;
/* OK let's complete stream initialization since there is no handshake */
cli_conn->flags |= CO_FL_CONNECTED;
- if (stream_new(sess, t))
- return 1;
+ strm = stream_new(sess, t);
+ if (!strm)
+ goto out_free_task;
+
+ strm->target = sess->listener->default_target;
+ strm->req.analysers = sess->listener->analysers;
+ return 1;
+ out_free_task:
task_free(t);
out_free_sess:
p->feconn--;
{
struct task *task = conn->owner;
struct session *sess = task->context;
+ struct stream *strm;
- if (!(conn->flags & CO_FL_ERROR) && (stream_new(sess, task) != NULL)) {
- conn->flags &= ~CO_FL_INIT_DATA;
- return 0;
- }
+ if (conn->flags & CO_FL_ERROR)
+ goto fail;
+
+ task->process = sess->listener->handler;
+ strm = stream_new(sess, task);
+ if (!strm)
+ goto fail;
+
+ strm->target = sess->listener->default_target;
+ strm->req.analysers = sess->listener->analysers;
+ conn->flags &= ~CO_FL_INIT_DATA;
+ return 0;
+ fail:
session_kill_embryonic(sess);
return -1;
}
* 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.
*/
struct stream *stream_new(struct session *sess, struct task *t)
{
struct stream *s;
- struct listener *l = sess->listener;
struct connection *conn = objt_conn(sess->origin);
struct appctx *appctx = objt_appctx(sess->origin);
int i;
s->unique_id = NULL;
s->task = t;
- t->process = l->handler;
+ t->process = process_stream;
t->context = s;
t->expire = TICK_ETERNITY;
s->res_cap = NULL;
/* Let's count a stream now */
- proxy_inc_fe_sess_ctr(l, sess->fe);
+ if (conn)
+ proxy_inc_fe_sess_ctr(sess->listener, sess->fe);
for (i = 0; i < MAX_SESS_STKCTR; i++) {
void *ptr;
s->si[1].flags |= SI_FL_INDEP_STR;
stream_init_srv_conn(s);
- s->target = l->default_target; /* used by peers and CLI */
+ s->target = NULL;
s->pend_pos = NULL;
/* init store persistence */
channel_init(&s->req);
s->req.flags |= CF_READ_ATTACHED; /* the producer is already connected */
-
- /* activate default analysers enabled for this listener */
- s->req.analysers = l->analysers;
-
- if (!s->req.analysers) {
- channel_auto_connect(&s->req); /* don't wait to establish connection */
- channel_auto_close(&s->req); /* let the producer forward close requests */
- }
+ s->req.analysers = 0;
+ channel_auto_connect(&s->req); /* don't wait to establish connection */
+ channel_auto_close(&s->req); /* let the producer forward close requests */
s->req.rto = sess->fe->timeout.client;
s->req.wto = TICK_ETERNITY;