MAJOR: buffer rework: replace ->send_max with ->o
This is the first minor step of the buffer rework. It's only renaming,
it should have no impact.
diff --git a/src/buffers.c b/src/buffers.c
index 88d40ff..0697d61 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -35,7 +35,7 @@
* in the limit of the number of bytes to forward. This must be the only method
* to use to schedule bytes to be sent. If the requested number is too large, it
* is automatically adjusted. The number of bytes taken into account is returned.
- * Directly touching ->to_forward will cause lockups when send_max goes down to
+ * Directly touching ->to_forward will cause lockups when ->o goes down to
* zero if nobody is ready to push the remaining data.
*/
unsigned long long buffer_forward(struct buffer *buf, unsigned long long bytes)
@@ -45,15 +45,15 @@
if (!bytes)
return 0;
- data_left = buf->l - buf->send_max;
+ data_left = buf->l - buf->o;
if (bytes <= (unsigned long long)data_left) {
- buf->send_max += bytes;
+ buf->o += bytes;
buf->flags &= ~BF_OUT_EMPTY;
return bytes;
}
- buf->send_max += data_left;
- if (buf->send_max)
+ buf->o += data_left;
+ if (buf->o)
buf->flags &= ~BF_OUT_EMPTY;
if (buf->l < buffer_max_len(buf))
@@ -115,7 +115,7 @@
memcpy(buf->r, msg, len);
buf->l += len;
- buf->send_max += len;
+ buf->o += len;
buf->r += len;
buf->total += len;
if (buf->r == buf->data + buf->size)
@@ -129,7 +129,7 @@
}
/* Tries to copy character <c> into buffer <buf> after length controls. The
- * send_max and to_forward pointers are updated. If the buffer's input is
+ * ->o and to_forward pointers are updated. If the buffer's input is
* closed, -2 is returned. If there is not enough room left in the buffer, -1
* is returned. Otherwise the number of bytes copied is returned (1). Buffer
* flags FULL, EMPTY and READ_PARTIAL are updated if some data can be
@@ -157,7 +157,7 @@
if (buf->to_forward >= 1) {
if (buf->to_forward != BUF_INFINITE_FORWARD)
buf->to_forward--;
- buf->send_max++;
+ buf->o++;
buf->flags &= ~BF_OUT_EMPTY;
}
@@ -166,7 +166,7 @@
}
/* Tries to copy block <blk> at once into buffer <buf> after length controls.
- * The send_max and to_forward pointers are updated. If the buffer's input is
+ * The ->o and to_forward pointers are updated. If the buffer's input is
* closed, -2 is returned. If the block is too large for this buffer, -3 is
* returned. If there is not enough room left in the buffer, -1 is returned.
* Otherwise the number of bytes copied is returned (0 being a valid number).
@@ -211,7 +211,7 @@
fwd = buf->to_forward;
buf->to_forward -= fwd;
}
- buf->send_max += fwd;
+ buf->o += fwd;
buf->flags &= ~BF_OUT_EMPTY;
}
@@ -254,8 +254,8 @@
p = buf->w;
- if (max > buf->send_max) {
- max = buf->send_max;
+ if (max > buf->o) {
+ max = buf->o;
str[max-1] = 0;
}
while (max) {
@@ -269,7 +269,7 @@
if (p == buf->data + buf->size)
p = buf->data;
}
- if (ret > 0 && ret < len && ret < buf->send_max &&
+ if (ret > 0 && ret < len && ret < buf->o &&
*(str-1) != '\n' &&
!(buf->flags & (BF_SHUTW|BF_SHUTW_NOW)))
ret = 0;
@@ -294,7 +294,7 @@
if (buf->flags & BF_SHUTW)
return -1;
- if (len + offset > buf->send_max) {
+ if (len + offset > buf->o) {
if (buf->flags & (BF_SHUTW|BF_SHUTW_NOW))
return -1;
return 0;
@@ -320,7 +320,7 @@
* buffer <b>, and moves <end> just after the end of <str>. <b>'s parameters
* (l, r, lr) are updated to be valid after the shift. the shift value
* (positive or negative) is returned. If there's no space left, the move is
- * not done. The function does not adjust ->send_max nor BF_OUT_EMPTY because
+ * not done. The function does not adjust ->o nor BF_OUT_EMPTY because
* it does not make sense to use it on data scheduled to be sent. The string
* length is taken from parameter <len>. If <len> is null, the <str> pointer
* is allowed to be null.
diff --git a/src/dumpstats.c b/src/dumpstats.c
index eeba7b4..907e2fe 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -1500,7 +1500,7 @@
* buffer is empty. This still allows pipelined requests
* to be sent in non-interactive mode.
*/
- if ((res->flags & (BF_SHUTW|BF_SHUTW_NOW)) || (!si->applet.st1 && !req->send_max)) {
+ if ((res->flags & (BF_SHUTW|BF_SHUTW_NOW)) || (!si->applet.st1 && !req->o)) {
si->applet.st0 = STAT_CLI_END;
continue;
}
@@ -1542,7 +1542,7 @@
out:
DPRINTF(stderr, "%s@%d: st=%d, rqf=%x, rpf=%x, rql=%d, rqs=%d, rl=%d, rs=%d\n",
__FUNCTION__, __LINE__,
- si->state, req->flags, res->flags, req->l, req->send_max, res->l, res->send_max);
+ si->state, req->flags, res->flags, req->l, req->o, res->l, res->o);
if (unlikely(si->state == SI_ST_DIS || si->state == SI_ST_CLO)) {
/* check that we have released everything then unregister */
@@ -3370,11 +3370,11 @@
chunk_printf(&msg,
- " req=%p (f=0x%06x an=0x%x l=%d sndmx=%d pipe=%d fwd=%d)\n"
+ " req=%p (f=0x%06x an=0x%x l=%d o=%d pipe=%d fwd=%d)\n"
" an_exp=%s",
sess->req,
sess->req->flags, sess->req->analysers,
- sess->req->l, sess->req->send_max,
+ sess->req->l, sess->req->o,
sess->req->pipe ? sess->req->pipe->data : 0,
sess->req->to_forward,
sess->req->analyse_exp ?
@@ -3400,11 +3400,11 @@
sess->req->total);
chunk_printf(&msg,
- " res=%p (f=0x%06x an=0x%x l=%d sndmx=%d pipe=%d fwd=%d)\n"
+ " res=%p (f=0x%06x an=0x%x l=%d o=%d pipe=%d fwd=%d)\n"
" an_exp=%s",
sess->rep,
sess->rep->flags, sess->rep->analysers,
- sess->rep->l, sess->rep->send_max,
+ sess->rep->l, sess->rep->o,
sess->rep->pipe ? sess->rep->pipe->data : 0,
sess->rep->to_forward,
sess->rep->analyse_exp ?
diff --git a/src/proto_http.c b/src/proto_http.c
index 0006f2f..0b62078 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -393,14 +393,14 @@
"[%04d] req: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p lr=%p sm=%d fw=%ld tf=%08x\n",
line,
s->si[0].state, s->si[0].fd, s->txn.req.msg_state, s->req->flags, s->req->analysers,
- s->req->data, s->req->size, s->req->l, s->req->w, s->req->r, s->req->lr, s->req->send_max, s->req->to_forward, s->txn.flags);
+ s->req->data, s->req->size, s->req->l, s->req->w, s->req->r, s->req->lr, s->req->o, s->req->to_forward, s->txn.flags);
write(-1, trash, size);
size = 0;
size += snprintf(trash + size, sizeof(trash) - size,
" %04d rep: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p lr=%p sm=%d fw=%ld\n",
line,
s->si[1].state, s->si[1].fd, s->txn.rsp.msg_state, s->rep->flags, s->rep->analysers,
- s->rep->data, s->rep->size, s->rep->l, s->rep->w, s->rep->r, s->rep->lr, s->rep->send_max, s->rep->to_forward);
+ s->rep->data, s->rep->size, s->rep->l, s->rep->w, s->rep->r, s->rep->lr, s->rep->o, s->rep->to_forward);
write(-1, trash, size);
}
@@ -1295,13 +1295,13 @@
if (likely(HTTP_IS_TOKEN(*ptr))) {
/* we have a start of message, but we have to check
* first if we need to remove some CRLF. We can only
- * do this when send_max=0.
+ * do this when o=0.
*/
- char *beg = buf->w + buf->send_max;
+ char *beg = buf->w + buf->o;
if (beg >= buf->data + buf->size)
beg -= buf->size;
if (unlikely(ptr != beg)) {
- if (buf->send_max)
+ if (buf->o)
goto http_msg_ood;
/* Remove empty leading lines, as recommended by RFC2616. */
buffer_ignore(buf, ptr - beg);
@@ -1364,13 +1364,13 @@
if (likely(HTTP_IS_TOKEN(*ptr))) {
/* we have a start of message, but we have to check
* first if we need to remove some CRLF. We can only
- * do this when send_max=0.
+ * do this when o=0.
*/
- char *beg = buf->w + buf->send_max;
+ char *beg = buf->w + buf->o;
if (beg >= buf->data + buf->size)
beg -= buf->size;
if (likely(ptr != beg)) {
- if (buf->send_max)
+ if (buf->o)
goto http_msg_ood;
/* Remove empty leading lines, as recommended by RFC2616. */
buffer_ignore(buf, ptr - beg);
@@ -1944,7 +1944,7 @@
ptr = buf->data;
}
- if (bytes > buf->l - buf->send_max)
+ if (bytes > buf->l - buf->o)
return 0;
if (*ptr != '\n') {
@@ -2069,7 +2069,7 @@
unlikely((req->flags & BF_FULL) ||
req->r < req->lr ||
req->r > req->data + req->size - global.tune.maxrewrite)) {
- if (req->send_max) {
+ if (req->o) {
if (req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_WRITE_ERROR|BF_WRITE_TIMEOUT))
goto failed_keep_alive;
/* some data has still not left the buffer, wake us once that's done */
@@ -2092,7 +2092,7 @@
unlikely((s->rep->flags & BF_FULL) ||
s->rep->r < s->rep->lr ||
s->rep->r > s->rep->data + s->rep->size - global.tune.maxrewrite)) {
- if (s->rep->send_max) {
+ if (s->rep->o) {
if (s->rep->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_WRITE_ERROR|BF_WRITE_TIMEOUT))
goto failed_keep_alive;
/* don't let a connection request be initiated */
@@ -3755,8 +3755,8 @@
}
/* don't count other requests' data */
- s->logs.bytes_in -= s->req->l - s->req->send_max;
- s->logs.bytes_out -= s->rep->l - s->rep->send_max;
+ s->logs.bytes_in -= s->req->l - s->req->o;
+ s->logs.bytes_out -= s->rep->l - s->rep->o;
/* let's do a final log if we need it */
if (s->logs.logwait &&
@@ -3775,8 +3775,8 @@
s->logs.prx_queue_size = 0; /* we get the number of pending conns before us */
s->logs.srv_queue_size = 0; /* we will get this number soon */
- s->logs.bytes_in = s->req->total = s->req->l - s->req->send_max;
- s->logs.bytes_out = s->rep->total = s->rep->l - s->rep->send_max;
+ s->logs.bytes_in = s->req->total = s->req->l - s->req->o;
+ s->logs.bytes_out = s->rep->total = s->rep->l - s->rep->o;
if (s->pend_pos)
pendconn_free(s->pend_pos);
@@ -3821,8 +3821,8 @@
* because the request will wait for it to flush a little
* bit before proceeding.
*/
- if (s->req->l > s->req->send_max) {
- if (s->rep->send_max &&
+ if (s->req->l > s->req->o) {
+ if (s->rep->o &&
!(s->rep->flags & BF_FULL) &&
s->rep->r <= s->rep->data + s->rep->size - global.tune.maxrewrite)
s->rep->flags |= BF_EXPECT_MORE;
@@ -3835,10 +3835,10 @@
buffer_auto_close(s->rep);
/* make ->lr point to the first non-forwarded byte */
- s->req->lr = s->req->w + s->req->send_max;
+ s->req->lr = s->req->w + s->req->o;
if (s->req->lr >= s->req->data + s->req->size)
s->req->lr -= s->req->size;
- s->rep->lr = s->rep->w + s->rep->send_max;
+ s->rep->lr = s->rep->w + s->rep->o;
if (s->rep->lr >= s->rep->data + s->rep->size)
s->rep->lr -= s->req->size;
@@ -4087,7 +4087,7 @@
if (txn->rsp.msg_state == HTTP_MSG_CLOSED) {
http_msg_closed:
/* drop any pending data */
- buffer_ignore(buf, buf->l - buf->send_max);
+ buffer_ignore(buf, buf->l - buf->o);
buffer_auto_close(buf);
buffer_auto_read(buf);
goto wait_other_side;
@@ -4153,7 +4153,7 @@
buffer_abort(s->req);
buffer_auto_close(s->req);
buffer_auto_read(s->req);
- buffer_ignore(s->req, s->req->l - s->req->send_max);
+ buffer_ignore(s->req, s->req->l - s->req->o);
}
else if (txn->req.msg_state == HTTP_MSG_CLOSED &&
txn->rsp.msg_state == HTTP_MSG_DONE &&
@@ -4189,7 +4189,7 @@
return 0;
if ((req->flags & (BF_READ_ERROR|BF_READ_TIMEOUT|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) ||
- ((req->flags & BF_SHUTW) && (req->to_forward || req->send_max))) {
+ ((req->flags & BF_SHUTW) && (req->to_forward || req->o))) {
/* Output closed while we were sending data. We must abort and
* wake the other side up.
*/
@@ -4267,7 +4267,7 @@
/* we want the CRLF after the data */
int ret;
- req->lr = req->w + req->send_max;
+ req->lr = req->w + req->o;
if (req->lr >= req->data + req->size)
req->lr -= req->size;
@@ -4494,7 +4494,7 @@
if (unlikely((rep->flags & BF_FULL) ||
rep->r < rep->lr ||
rep->r > rep->data + rep->size - global.tune.maxrewrite)) {
- if (rep->send_max) {
+ if (rep->o) {
/* some data has still not left the buffer, wake us once that's done */
if (rep->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_WRITE_ERROR|BF_WRITE_TIMEOUT))
goto abort_response;
@@ -4565,7 +4565,7 @@
rep->analysers = 0;
txn->status = 502;
rep->prod->flags |= SI_FL_NOLINGER;
- buffer_ignore(rep, rep->l - rep->send_max);
+ buffer_ignore(rep, rep->l - rep->o);
stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_502));
if (!(s->flags & SN_ERR_MASK))
@@ -4598,7 +4598,7 @@
rep->analysers = 0;
txn->status = 502;
rep->prod->flags |= SI_FL_NOLINGER;
- buffer_ignore(rep, rep->l - rep->send_max);
+ buffer_ignore(rep, rep->l - rep->o);
stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_502));
if (!(s->flags & SN_ERR_MASK))
@@ -4623,7 +4623,7 @@
rep->analysers = 0;
txn->status = 504;
rep->prod->flags |= SI_FL_NOLINGER;
- buffer_ignore(rep, rep->l - rep->send_max);
+ buffer_ignore(rep, rep->l - rep->o);
stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_504));
if (!(s->flags & SN_ERR_MASK))
@@ -4648,7 +4648,7 @@
rep->analysers = 0;
txn->status = 502;
rep->prod->flags |= SI_FL_NOLINGER;
- buffer_ignore(rep, rep->l - rep->send_max);
+ buffer_ignore(rep, rep->l - rep->o);
stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_502));
if (!(s->flags & SN_ERR_MASK))
@@ -4998,7 +4998,7 @@
rep->analysers = 0;
txn->status = 502;
rep->prod->flags |= SI_FL_NOLINGER;
- buffer_ignore(rep, rep->l - rep->send_max);
+ buffer_ignore(rep, rep->l - rep->o);
stream_int_retnclose(rep->cons, error_message(t, HTTP_ERR_502));
if (!(t->flags & SN_ERR_MASK))
t->flags |= SN_ERR_PRXCOND;
@@ -5259,7 +5259,7 @@
return 0;
if ((res->flags & (BF_READ_ERROR|BF_READ_TIMEOUT|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) ||
- ((res->flags & BF_SHUTW) && (res->to_forward || res->send_max)) ||
+ ((res->flags & BF_SHUTW) && (res->to_forward || res->o)) ||
!s->req->analysers) {
/* Output closed while we were sending data. We must abort and
* wake the other side up.
@@ -5331,7 +5331,7 @@
/* we want the CRLF after the data */
int ret;
- res->lr = res->w + res->send_max;
+ res->lr = res->w + res->o;
if (res->lr >= res->data + res->size)
res->lr -= res->size;
@@ -7456,8 +7456,8 @@
* a HEAD with some data, or sending more than the advertised
* content-length.
*/
- if (unlikely(s->rep->l > s->rep->send_max)) {
- s->rep->l = s->rep->send_max;
+ if (unlikely(s->rep->l > s->rep->o)) {
+ s->rep->l = s->rep->o;
s->rep->r = s->rep->w + s->rep->l;
if (s->rep->r >= s->rep->data + s->rep->size)
s->rep->r -= s->rep->size;
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 8966ad3..2a25420 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -393,7 +393,7 @@
* machine with the first ACK. We only do this if there are pending
* data in the buffer.
*/
- if ((be->options2 & PR_O2_SMARTCON) && si->ob->send_max)
+ if ((be->options2 & PR_O2_SMARTCON) && si->ob->o)
setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &zero, sizeof(zero));
#endif
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 44d9e11..36120a1 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -301,7 +301,7 @@
b->l += ret;
cur_read += ret;
- /* if we're allowed to directly forward data, we must update send_max */
+ /* if we're allowed to directly forward data, we must update ->o */
if (b->to_forward && !(b->flags & (BF_SHUTW|BF_SHUTW_NOW))) {
unsigned long fwd = ret;
if (b->to_forward != BUF_INFINITE_FORWARD) {
@@ -309,7 +309,7 @@
fwd = b->to_forward;
b->to_forward -= fwd;
}
- b->send_max += fwd;
+ b->o += fwd;
b->flags &= ~BF_OUT_EMPTY;
}
@@ -446,7 +446,7 @@
* HTTP chunking).
*/
if (b->pipe || /* always try to send spliced data */
- (b->send_max == b->l && (b->cons->flags & SI_FL_WAIT_DATA))) {
+ (b->o == b->l && (b->cons->flags & SI_FL_WAIT_DATA))) {
int last_len = b->pipe ? b->pipe->data : 0;
b->cons->chk_snd(b->cons);
@@ -588,7 +588,7 @@
* in the normal buffer.
*/
#endif
- if (!b->send_max) {
+ if (!b->o) {
b->flags |= BF_OUT_EMPTY;
return retval;
}
@@ -603,8 +603,8 @@
max = b->data + b->size - b->w;
/* limit the amount of outgoing data if required */
- if (max > b->send_max)
- max = b->send_max;
+ if (max > b->o)
+ max = b->o;
/* check if we want to inform the kernel that we're interested in
* sending more data after this call. We want this if :
@@ -623,8 +623,8 @@
if ((!(b->flags & BF_NEVER_WAIT) &&
((b->to_forward && b->to_forward != BUF_INFINITE_FORWARD) ||
(b->flags & BF_EXPECT_MORE))) ||
- ((b->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == BF_SHUTW_NOW && (max == b->send_max)) ||
- (max != b->l && max != b->send_max)) {
+ ((b->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == BF_SHUTW_NOW && (max == b->o)) ||
+ (max != b->l && max != b->o)) {
send_flag |= MSG_MORE;
}
@@ -662,8 +662,8 @@
/* optimize data alignment in the buffer */
b->r = b->w = b->lr = b->data;
- b->send_max -= ret;
- if (!b->send_max) {
+ b->o -= ret;
+ if (!b->o) {
/* Always clear both flags once everything has been sent, they're one-shot */
b->flags &= ~(BF_EXPECT_MORE | BF_SEND_DONTWAIT);
if (likely(!b->pipe))
@@ -757,7 +757,7 @@
/* Funny, we were called to write something but there wasn't
* anything. We can get there, for example if we were woken up
- * on a write event to finish the splice, but the send_max is 0
+ * on a write event to finish the splice, but the ->o is 0
* so we cannot write anything from the buffer. Let's disable
* the write event and pretend we never came there.
*/
@@ -766,7 +766,7 @@
if (b->flags & BF_OUT_EMPTY) {
/* the connection is established but we can't write. Either the
* buffer is empty, or we just refrain from sending because the
- * send_max limit was reached. Maybe we just wrote the last
+ * ->o limit was reached. Maybe we just wrote the last
* chunk and need to close.
*/
if (((b->flags & (BF_SHUTW|BF_HIJACK|BF_SHUTW_NOW)) == BF_SHUTW_NOW) &&
@@ -1097,7 +1097,7 @@
if (ob->flags & BF_OUT_EMPTY) {
/* the connection is established but we can't write. Either the
* buffer is empty, or we just refrain from sending because the
- * send_max limit was reached. Maybe we just wrote the last
+ * ->o limit was reached. Maybe we just wrote the last
* chunk and need to close.
*/
if (((ob->flags & (BF_SHUTW|BF_HIJACK|BF_AUTO_CLOSE|BF_SHUTW_NOW)) ==