MINOR: buffer: reset a buffer in b_reset() and not channel_init()
We'll soon need to be able to switch buffers without touching the
channel, so let's move buffer initialization out of channel_init().
We had the same in compressoin.c.
diff --git a/src/compression.c b/src/compression.c
index 3d6085e..b6c4ae2 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -139,9 +139,7 @@
*/
out->size = global.tune.bufsize;
- out->i = 0;
- out->o = 0;
- out->p = out->data;
+ b_reset(out);
if (in->o > 0) {
left = in->o - bo_contig_data(in);
diff --git a/src/peers.c b/src/peers.c
index b196d88..9ff1773 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1241,6 +1241,7 @@
goto out_fail_req_buf; /* no memory */
s->req->buf->size = global.tune.bufsize;
+ b_reset(s->req->buf);
channel_init(s->req);
s->req->prod = &s->si[0];
s->req->cons = &s->si[1];
@@ -1267,6 +1268,7 @@
goto out_fail_rep_buf; /* no memory */
s->rep->buf->size = global.tune.bufsize;
+ b_reset(s->rep->buf);
channel_init(s->rep);
s->rep->prod = &s->si[1];
s->rep->cons = &s->si[0];
diff --git a/src/session.c b/src/session.c
index 7723074..d57a2d5 100644
--- a/src/session.c
+++ b/src/session.c
@@ -488,6 +488,7 @@
/* initialize the request buffer */
s->req->buf->size = global.tune.bufsize;
+ b_reset(s->req->buf);
channel_init(s->req);
s->req->prod = &s->si[0];
s->req->cons = &s->si[1];
@@ -505,6 +506,7 @@
/* initialize response buffer */
s->rep->buf->size = global.tune.bufsize;
+ b_reset(s->rep->buf);
channel_init(s->rep);
s->rep->prod = &s->si[1];
s->rep->cons = &s->si[0];