Commit 49ca223e authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Minor memory optimization

Release pbuf sooner: after copying data from, before invoking user code

PUBLISHED_FROM=b877c96ef602bbca26762b18b9dde17eb880d1f9
parent 38efe632
......@@ -13928,15 +13928,15 @@ static void mg_lwip_handle_recv_tcp(struct mg_connection *nc) {
return;
}
pbuf_copy_partial(seg, data, len, cs->rx_offset);
mgos_unlock();
mg_if_recv_tcp_cb(nc, data, len, 1 /* own */);
mgos_lock();
cs->rx_offset += len;
if (cs->rx_offset == cs->rx_chain->len) {
cs->rx_chain = pbuf_dechain(cs->rx_chain);
pbuf_free(seg);
cs->rx_offset = 0;
}
mgos_unlock();
mg_if_recv_tcp_cb(nc, data, len, 1 /* own */);
mgos_lock();
}
mgos_unlock();
......
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