From: Willy Tarreau Date: Sat, 4 Apr 2015 22:46:36 +0000 (+0200) Subject: MEDIUM: peers: initialize the task before the stream X-Git-Tag: v1.6-dev2~239 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8baf906366dd6c31d31e5d52ec2adb12ee795f88;p=thirdparty%2Fhaproxy.git MEDIUM: peers: initialize the task before the stream Thanks to this we should be able to make use of stream_accept_session() now. --- diff --git a/src/peers.c b/src/peers.c index 5995adcf5e..ad66af59fe 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1134,30 +1134,28 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session goto out_free_appctx; } - if ((s = pool_alloc2(pool2_stream)) == NULL) { /* disable this proxy for a while */ + if ((t = task_new()) == NULL) { 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"); + goto out_free_task; + } + LIST_ADDQ(&streams, &s->list); LIST_INIT(&s->back_refs); LIST_INIT(&s->buffer_wait); s->flags = SF_ASSIGNED|SF_ADDR_SET; - /* if this session comes from a known monitoring system, we want to ignore - * it as soon as possible, which means closing it immediately for TCP. - */ - if ((t = task_new()) == NULL) { /* disable this proxy for a while */ - Alert("out of memory in peer_session_create().\n"); - goto out_free_strm; - } - - t->process = l->handler; - t->context = s; - t->nice = l->nice; - s->task = t; + t->context = s; s->sess = sess; s->be = s->sess->fe; s->req.buf = s->res.buf = NULL; @@ -1189,7 +1187,7 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session * pre-initialized connection in si->conn. */ if (unlikely((conn = conn_new()) == NULL)) - goto out_free_task; + goto out_free_strm; conn_prepare(conn, peer->proto, peer->xprt); si_attach_conn(&s->si[1], conn); @@ -1270,11 +1268,11 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session return s; /* Error unrolling */ - out_free_task: - task_free(t); out_free_strm: LIST_DEL(&s->list); pool_free2(pool2_stream, s); + out_free_task: + task_free(t); out_free_sess: session_free(sess); out_free_appctx: