CLEANUP: stream-int: add si_ib/si_ob to dereference the buffers
This makes the code cleaner and is more intuitive to use.
diff --git a/src/dumpstats.c b/src/dumpstats.c
index dab7189..56512e7 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -2263,7 +2263,7 @@
/* ensure we have some output room left in the event we
* would want to return some info right after parsing.
*/
- if (buffer_almost_full(si_ic(si)->buf)) {
+ if (buffer_almost_full(si_ib(si))) {
si_ic(si)->flags |= CF_WAKE_WRITE;
break;
}
@@ -3625,7 +3625,7 @@
scope_txt[0] = 0;
if (appctx->ctx.stats.scope_len) {
strcpy(scope_txt, STAT_SCOPE_PATTERN);
- memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_oc(si)->buf) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
}
@@ -3778,7 +3778,7 @@
* name does not match, skip it.
*/
if (appctx->ctx.stats.scope_len &&
- strnistr(px->id, strlen(px->id), bo_ptr(si_oc(si)->buf) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len) == NULL)
+ strnistr(px->id, strlen(px->id), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len) == NULL)
return 1;
if ((appctx->ctx.stats.flags & STAT_BOUND) &&
@@ -4134,7 +4134,7 @@
);
/* scope_txt = search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
- memcpy(scope_txt, bo_ptr(si_oc(si)->buf) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt, bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
scope_txt[appctx->ctx.stats.scope_len] = '\0';
chunk_appendf(&trash,
@@ -4149,7 +4149,7 @@
scope_txt[0] = 0;
if (appctx->ctx.stats.scope_len) {
strcpy(scope_txt, STAT_SCOPE_PATTERN);
- memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_oc(si)->buf) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
}
@@ -4756,7 +4756,7 @@
scope_txt[0] = 0;
if (appctx->ctx.stats.scope_len) {
strcpy(scope_txt, STAT_SCOPE_PATTERN);
- memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_oc(si)->buf) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
}
@@ -4820,7 +4820,7 @@
}
if (appctx->st0 == STAT_HTTP_DUMP) {
- unsigned int prev_len = si_ic(si)->buf->i;
+ unsigned int prev_len = si_ib(si)->i;
unsigned int data_len;
unsigned int last_len;
unsigned int last_fwd = 0;
@@ -4840,11 +4840,11 @@
}
}
- data_len = si_ic(si)->buf->i;
+ data_len = si_ib(si)->i;
if (stats_dump_stat_to_buffer(si, s->be->uri_auth))
appctx->st0 = STAT_HTTP_DONE;
- last_len = si_ic(si)->buf->i;
+ last_len = si_ib(si)->i;
/* Now we must either adjust or remove the chunk size. This is
* not easy because the chunk size might wrap at the end of the
@@ -4854,15 +4854,15 @@
* applet.
*/
if (appctx->ctx.stats.flags & STAT_CHUNKED) {
- si_ic(si)->total -= (last_len - prev_len);
- si_ic(si)->buf->i -= (last_len - prev_len);
+ si_ic(si)->total -= (last_len - prev_len);
+ si_ib(si)->i -= (last_len - prev_len);
if (last_len != data_len) {
chunk_printf(&trash, "\r\n%06x\r\n", (last_len - data_len));
bi_putchk(si_ic(si), &trash);
- si_ic(si)->total += (last_len - data_len);
- si_ic(si)->buf->i += (last_len - data_len);
+ si_ic(si)->total += (last_len - data_len);
+ si_ib(si)->i += (last_len - data_len);
}
/* now re-enable forwarding */
channel_forward(si_ic(si), last_fwd);
@@ -4888,7 +4888,7 @@
goto fail;
}
/* eat the whole request */
- bo_skip(si_oc(si), si_oc(si)->buf->o);
+ bo_skip(si_oc(si), si_ob(si)->o);
res->flags |= CF_READ_NULL;
si_shutr(si);
}
diff --git a/src/hlua.c b/src/hlua.c
index 83a8683..b003750 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -1445,7 +1445,7 @@
}
/* Check for avalaible space. */
- len = buffer_total_space(si_ic(&socket->s->si[0])->buf);
+ len = buffer_total_space(si_ib(&socket->s->si[0]));
if (len <= 0)
goto hlua_socket_write_yield_return;
diff --git a/src/peers.c b/src/peers.c
index 10cc7ff..805b8d0 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -647,7 +647,7 @@
to_store = 0;
to_read = ntohl(netinteger);
- if (to_read + totl > si_oc(si)->buf->size) {
+ if (to_read + totl > si_ob(si)->size) {
/* impossible to read a key this large, abort */
reql = -1;
goto incomplete;
diff --git a/src/stream_interface.c b/src/stream_interface.c
index bfc67c2..f45678f 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -181,7 +181,7 @@
if (((si_ic(si)->flags & CF_READ_PARTIAL) && !channel_is_empty(si_ic(si))) &&
(si_ic(si)->pipe /* always try to send spliced data */ ||
- (si_ic(si)->buf->i == 0 && (si_ic(si)->cons->flags & SI_FL_WAIT_DATA)))) {
+ (si_ib(si)->i == 0 && (si_ic(si)->cons->flags & SI_FL_WAIT_DATA)))) {
si_chk_snd(si_ic(si)->cons);
/* check if the consumer has freed some space */
if (channel_may_recv(si_ic(si)) && !si_ic(si)->pipe)
@@ -599,7 +599,7 @@
*/
if (((si_ic(si)->flags & CF_READ_PARTIAL) && !channel_is_empty(si_ic(si))) &&
(si_ic(si)->pipe /* always try to send spliced data */ ||
- (si_ic(si)->buf->i == 0 && (si_ic(si)->cons->flags & SI_FL_WAIT_DATA)))) {
+ (si_ib(si)->i == 0 && (si_ic(si)->cons->flags & SI_FL_WAIT_DATA)))) {
int last_len = si_ic(si)->pipe ? si_ic(si)->pipe->data : 0;
si_chk_snd(si_ic(si)->cons);