Commit 93286836 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Read all available data during recv poll

CL: mg: Read all available data during recv poll

PUBLISHED_FROM=b081025b9fb392c988924c7097b5333c38053f6f
parent 91b57aa9
...@@ -2882,6 +2882,7 @@ static int mg_do_recv(struct mg_connection *nc) { ...@@ -2882,6 +2882,7 @@ static int mg_do_recv(struct mg_connection *nc) {
((nc->flags & MG_F_LISTENING) && !(nc->flags & MG_F_UDP))) { ((nc->flags & MG_F_LISTENING) && !(nc->flags & MG_F_UDP))) {
return -1; return -1;
} }
do {
len = recv_avail_size(nc, len); len = recv_avail_size(nc, len);
if (len == 0) return -2; if (len == 0) return -2;
if (nc->recv_mbuf.size < nc->recv_mbuf.len + len) { if (nc->recv_mbuf.size < nc->recv_mbuf.len + len) {
...@@ -2894,6 +2895,7 @@ static int mg_do_recv(struct mg_connection *nc) { ...@@ -2894,6 +2895,7 @@ static int mg_do_recv(struct mg_connection *nc) {
} else { } else {
res = mg_recv_tcp(nc, buf, len); res = mg_recv_tcp(nc, buf, len);
} }
} while (res > 0);
return res; return res;
} }
......
...@@ -565,6 +565,7 @@ static int mg_do_recv(struct mg_connection *nc) { ...@@ -565,6 +565,7 @@ static int mg_do_recv(struct mg_connection *nc) {
((nc->flags & MG_F_LISTENING) && !(nc->flags & MG_F_UDP))) { ((nc->flags & MG_F_LISTENING) && !(nc->flags & MG_F_UDP))) {
return -1; return -1;
} }
do {
len = recv_avail_size(nc, len); len = recv_avail_size(nc, len);
if (len == 0) return -2; if (len == 0) return -2;
if (nc->recv_mbuf.size < nc->recv_mbuf.len + len) { if (nc->recv_mbuf.size < nc->recv_mbuf.len + len) {
...@@ -577,6 +578,7 @@ static int mg_do_recv(struct mg_connection *nc) { ...@@ -577,6 +578,7 @@ static int mg_do_recv(struct mg_connection *nc) {
} else { } else {
res = mg_recv_tcp(nc, buf, len); res = mg_recv_tcp(nc, buf, len);
} }
} while (res > 0);
return res; return res;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment