in pull_all() and read_request(), respect ctx->stop_flag()

This commit is contained in:
Sergey Lyubka 2013-07-16 17:17:36 +01:00
parent 8ce1562f0d
commit 7ca5962d2d

View File

@ -1528,7 +1528,7 @@ static int pull(FILE *fp, struct mg_connection *conn, char *buf, int len) {
static int pull_all(FILE *fp, struct mg_connection *conn, char *buf, int len) {
int n, nread = 0;
while (len > 0) {
while (len > 0 && conn->ctx->stop_flag == 0) {
n = pull(fp, conn, buf + nread, len);
if (n < 0) {
nread = n; // Propagate the error
@ -3052,7 +3052,8 @@ static int read_request(FILE *fp, struct mg_connection *conn,
int request_len, n = 0;
request_len = get_request_len(buf, *nread);
while (*nread < bufsiz && request_len == 0 &&
while (conn->ctx->stop_flag == 0 &&
*nread < bufsiz && request_len == 0 &&
(n = pull(fp, conn, buf + *nread, bufsiz - *nread)) > 0) {
*nread += n;
assert(*nread <= bufsiz);