diff --git a/src/peers.c b/src/peers.c index ad66af59f..1b0fa1047 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1138,51 +1138,23 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session Alert("out of memory in peer_session_create().\n"); goto out_free_sess; } - - t->process = l->handler; - t->context = sess; t->nice = l->nice; - if ((s = pool_alloc2(pool2_stream)) == NULL) { /* disable this proxy for a while */ - Alert("out of memory in peer_session_create().\n"); + if (stream_accept_session(sess, t) <= 0) { + Alert("Failed to initialize stream in peer_session_create().\n"); goto out_free_task; } - LIST_ADDQ(&streams, &s->list); - LIST_INIT(&s->back_refs); - LIST_INIT(&s->buffer_wait); - + /* The tasks below are normally what is supposed to be done by + * fe->accept(). + */ + s = t->context; // For now the session is not stored anywhere else :-/ s->flags = SF_ASSIGNED|SF_ADDR_SET; - s->task = t; - t->context = s; - s->sess = sess; - s->be = s->sess->fe; - s->req.buf = s->res.buf = NULL; - s->req_cap = NULL; - s->res_cap = NULL; - - s->si[0].flags = SI_FL_NONE; - s->si[1].flags = SI_FL_ISBACK; - - si_reset(&s->si[0]); - si_set_state(&s->si[0], SI_ST_EST); - - if (s->sess->fe->options2 & PR_O2_INDEPSTR) - s->si[0].flags |= SI_FL_INDEP_STR; - - si_attach_appctx(&s->si[0], appctx); - s->si[0].flags |= SI_FL_WAIT_DATA; - - si_reset(&s->si[1]); - /* initiate an outgoing connection */ si_set_state(&s->si[1], SI_ST_ASS); s->si[1].conn_retries = p->conn_retries; - if (s->be->options2 & PR_O2_INDEPSTR) - s->si[1].flags |= SI_FL_INDEP_STR; - /* automatically prepare the stream interface to connect to the * pre-initialized connection in si->conn. */ @@ -1194,70 +1166,25 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session conn->target = s->target = &s->be->obj_type; memcpy(&conn->addr.to, &peer->addr, sizeof(conn->addr.to)); - - stream_init_srv_conn(s); - s->pend_pos = NULL; - - /* init store persistence */ - s->store_count = 0; - memset(s->stkctr, 0, sizeof(s->stkctr)); - - /* FIXME: the logs are horribly complicated now, because they are - * defined in
,
, and later