MEDIUM: http: msg->sov and msg->sol will never wrap
These ones are offsets now, so they cannot wrap. Let's remove the useless
wrapping detection and simplify the forwarding code.
diff --git a/src/proto_http.c b/src/proto_http.c
index 6a3be49..157694f 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -4181,17 +4181,15 @@
}
while (1) {
- int bytes;
+ unsigned int bytes;
http_silent_debug(__LINE__, s);
- /* we may have some data pending */
+ /* we may have some data pending between sol and sov */
bytes = msg->sov - msg->sol;
if (msg->chunk_len || bytes) {
msg->sol = msg->sov;
- if (likely(bytes < 0)) /* sov may have wrapped at the end */
- bytes += req->size;
msg->next -= bytes; /* will be forwarded */
- msg->chunk_len += (unsigned int)bytes;
+ msg->chunk_len += bytes;
msg->chunk_len -= buffer_forward(req, msg->chunk_len);
}
@@ -5205,7 +5203,7 @@
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.rsp;
- int bytes;
+ unsigned int bytes;
if (unlikely(msg->msg_state < HTTP_MSG_BODY))
return 0;
@@ -5240,17 +5238,13 @@
}
while (1) {
- int bytes;
-
http_silent_debug(__LINE__, s);
- /* we may have some data pending */
+ /* we may have some data pending between sol and sov */
bytes = msg->sov - msg->sol;
if (msg->chunk_len || bytes) {
msg->sol = msg->sov;
- if (likely(bytes < 0)) /* sov may have wrapped at the end */
- bytes += res->size;
msg->next -= bytes; /* will be forwarded */
- msg->chunk_len += (unsigned int)bytes;
+ msg->chunk_len += bytes;
msg->chunk_len -= buffer_forward(res, msg->chunk_len);
}
@@ -5356,14 +5350,12 @@
if (!s->req->analysers)
goto return_bad_res;
- /* forward any pending data */
+ /* forward any data pending between sol and sov */
bytes = msg->sov - msg->sol;
if (msg->chunk_len || bytes) {
msg->sol = msg->sov;
- if (likely(bytes < 0)) /* sov may have wrapped at the end */
- bytes += res->size;
msg->next -= bytes; /* will be forwarded */
- msg->chunk_len += (unsigned int)bytes;
+ msg->chunk_len += bytes;
msg->chunk_len -= buffer_forward(res, msg->chunk_len);
}