mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-21 19:51:50 +00:00
Fixed assert for keepalive code path
This commit is contained in:
1 parent
49bac31d2d
commit
845d7b08e1
1 file changed
+6
-7
+6
-7
@@ -2882,6 +2882,7 @@ static int read_request(FILE *fp, struct mg_connection *conn,
|
|||||||
while (*nread < bufsiz && request_len == 0 &&
|
while (*nread < bufsiz && request_len == 0 &&
|
||||||
(n = pull(fp, conn, buf + *nread, bufsiz - *nread)) > 0) {
|
(n = pull(fp, conn, buf + *nread, bufsiz - *nread)) > 0) {
|
||||||
*nread += n;
|
*nread += n;
|
||||||
|
assert(*nread <= bufsiz);
|
||||||
request_len = get_request_len(buf, *nread);
|
request_len = get_request_len(buf, *nread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4821,21 +4822,19 @@ static void process_new_connection(struct mg_connection *conn) {
|
|||||||
// is using parsed request, which will be invalid after memmove's below.
|
// is using parsed request, which will be invalid after memmove's below.
|
||||||
// Therefore, memorize should_keep_alive() result now for later use
|
// Therefore, memorize should_keep_alive() result now for later use
|
||||||
// in loop exit condition.
|
// in loop exit condition.
|
||||||
keep_alive = should_keep_alive(conn);
|
keep_alive = conn->ctx->stop_flag == 0 && keep_alive_enabled &&
|
||||||
|
conn->content_len >= 0 && should_keep_alive(conn);
|
||||||
|
|
||||||
// Discard all buffered data for this request
|
// Discard all buffered data for this request
|
||||||
discard_len = conn->content_len >= 0 &&
|
discard_len = conn->content_len >= 0 && conn->request_len > 0 &&
|
||||||
conn->request_len + conn->content_len < (int64_t) conn->data_len ?
|
conn->request_len + conn->content_len < (int64_t) conn->data_len ?
|
||||||
(int) (conn->request_len + conn->content_len) : conn->data_len;
|
(int) (conn->request_len + conn->content_len) : conn->data_len;
|
||||||
|
assert(discard_len >= 0);
|
||||||
memmove(conn->buf, conn->buf + discard_len, conn->data_len - discard_len);
|
memmove(conn->buf, conn->buf + discard_len, conn->data_len - discard_len);
|
||||||
conn->data_len -= discard_len;
|
conn->data_len -= discard_len;
|
||||||
assert(conn->data_len >= 0);
|
assert(conn->data_len >= 0);
|
||||||
assert(conn->data_len <= conn->buf_size);
|
assert(conn->data_len <= conn->buf_size);
|
||||||
|
} while (keep_alive);
|
||||||
} while (conn->ctx->stop_flag == 0 &&
|
|
||||||
keep_alive_enabled &&
|
|
||||||
conn->content_len >= 0 &&
|
|
||||||
keep_alive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worker threads take accepted socket from the queue
|
// Worker threads take accepted socket from the queue
|
||||||
|
|||||||
Reference in new issue
Block a user