MINOR: session: group buffer allocations together

We'll soon want to release buffers together upon failure so we need to
allocate them after the channels. Let's change this now. There's no
impact on the behaviour, only the error path is unrolled slightly
differently. The same was done in peers.
diff --git a/src/peers.c b/src/peers.c
index 5371e49..84356e6 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1256,9 +1256,6 @@
 	s->req->rto = s->fe->timeout.client;
 	s->req->wto = s->be->timeout.server;
 
-	if (unlikely(b_alloc(&s->req->buf) == NULL))
-		goto out_fail_req_buf; /* no memory */
-
 	if ((s->rep = pool_alloc2(pool2_channel)) == NULL)
 		goto out_fail_rep; /* no memory */
 
@@ -1280,6 +1277,9 @@
 
 	s->rep->flags |= CF_READ_DONTWAIT;
 
+	if (unlikely(b_alloc(&s->req->buf) == NULL))
+		goto out_fail_req_buf; /* no memory */
+
 	if (unlikely(b_alloc(&s->rep->buf) == NULL))
 		goto out_fail_rep_buf; /* no memory */
 
@@ -1300,10 +1300,10 @@
 
 	/* Error unrolling */
  out_fail_rep_buf:
-	pool_free2(pool2_channel, s->rep);
- out_fail_rep:
 	b_free(&s->req->buf);
  out_fail_req_buf:
+	pool_free2(pool2_channel, s->rep);
+ out_fail_rep:
 	pool_free2(pool2_channel, s->req);
  out_fail_req:
 	conn_free(conn);
diff --git a/src/session.c b/src/session.c
index ebe992b..fbeb9cf 100644
--- a/src/session.c
+++ b/src/session.c
@@ -492,11 +492,8 @@
 	s->req->wex = TICK_ETERNITY;
 	s->req->analyse_exp = TICK_ETERNITY;
 
-	if (unlikely(b_alloc(&s->req->buf) == NULL))
-		goto out_free_req; /* no memory */
-
 	if (unlikely((s->rep = pool_alloc2(pool2_channel)) == NULL))
-		goto out_free_req_buf; /* no memory */
+		goto out_free_req; /* no memory */
 
 	channel_init(s->rep);
 	s->rep->prod = &s->si[1];
@@ -515,9 +512,12 @@
 	s->rep->wex = TICK_ETERNITY;
 	s->rep->analyse_exp = TICK_ETERNITY;
 
-	if (unlikely(b_alloc(&s->rep->buf) == NULL))
+	if (unlikely(b_alloc(&s->req->buf) == NULL))
 		goto out_free_rep; /* no memory */
 
+	if (unlikely(b_alloc(&s->rep->buf) == NULL))
+		goto out_free_req_buf; /* no memory */
+
 	txn = &s->txn;
 	/* Those variables will be checked and freed if non-NULL in
 	 * session.c:session_free(). It is important that they are
@@ -566,10 +566,10 @@
 	/* Error unrolling */
  out_free_rep_buf:
 	b_free(&s->rep->buf);
- out_free_rep:
-	pool_free2(pool2_channel, s->rep);
  out_free_req_buf:
 	b_free(&s->req->buf);
+ out_free_rep:
+	pool_free2(pool2_channel, s->rep);
  out_free_req:
 	pool_free2(pool2_channel, s->req);
  out_free_task: