Skip to content

Commit

Permalink
Respect recv_mbuf_limit in lwip
Browse files Browse the repository at this point in the history
PUBLISHED_FROM=470ff0f484bff3e4478651f0b64cc160bba8ebfc
dimonomid authored and cesantabot committed Dec 28, 2017
1 parent 608891f commit 1ce8adf
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions common/platforms/lwip/mg_lwip_net_if.c
Original file line number Diff line number Diff line change
@@ -187,9 +187,12 @@ static void mg_lwip_handle_recv_tcp(struct mg_connection *nc) {
#endif

mgos_lock();
while (cs->rx_chain != NULL) {
while (cs->rx_chain != NULL && nc->recv_mbuf.len < nc->recv_mbuf_limit) {
struct pbuf *seg = cs->rx_chain;
size_t len = (seg->len - cs->rx_offset);
size_t seg_len = (seg->len - cs->rx_offset);
size_t buf_avail = (nc->recv_mbuf_limit - nc->recv_mbuf.len);
size_t len = MIN(seg_len, buf_avail);

char *data = (char *) MG_MALLOC(len);
if (data == NULL) {
mgos_unlock();
7 changes: 5 additions & 2 deletions mongoose/mongoose.c
Original file line number Diff line number Diff line change
@@ -15003,9 +15003,12 @@ static void mg_lwip_handle_recv_tcp(struct mg_connection *nc) {
#endif

mgos_lock();
while (cs->rx_chain != NULL) {
while (cs->rx_chain != NULL && nc->recv_mbuf.len < nc->recv_mbuf_limit) {
struct pbuf *seg = cs->rx_chain;
size_t len = (seg->len - cs->rx_offset);
size_t seg_len = (seg->len - cs->rx_offset);
size_t buf_avail = (nc->recv_mbuf_limit - nc->recv_mbuf.len);
size_t len = MIN(seg_len, buf_avail);

char *data = (char *) MG_MALLOC(len);
if (data == NULL) {
mgos_unlock();

0 comments on commit 1ce8adf

Please sign in to comment.