Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net functionality rewrite on top of LWIP #1379

Merged
merged 14 commits into from
Dec 31, 2016
16 changes: 13 additions & 3 deletions app/modules/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static err_t net_tcp_recv_cb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, er
return tcp_close(tpcb);
}
net_recv_cb(ud, p, 0, 0);
tcp_recved(tpcb, p->len);
tcp_recved(tpcb, ud->client.hold ? 0 : TCP_WND);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really safe to use TCP_WND here rather than p->len (or possibly an accumulation of p->len from all packets received since the hold started)

return ERR_OK;
}

Expand Down Expand Up @@ -569,7 +569,12 @@ int net_hold( lua_State *L ) {
lnet_userdata *ud = net_get_udata(L);
if (!ud || ud->type != TYPE_TCP_CLIENT)
return luaL_error(L, "invalid user data");
ud->client.hold = 1;
if (!ud->client.hold && ud->tcp_pcb) {
ud->client.hold = 1;
ud->tcp_pcb->rcv_wnd = 0;
ud->tcp_pcb->flags |= TF_ACK_NOW;
tcp_recved(ud->tcp_pcb, 0);
}
return 0;
}

Expand All @@ -578,7 +583,12 @@ int net_unhold( lua_State *L ) {
lnet_userdata *ud = net_get_udata(L);
if (!ud || ud->type != TYPE_TCP_CLIENT)
return luaL_error(L, "invalid user data");
ud->client.hold = 0;
if (ud->client.hold && ud->tcp_pcb) {
ud->client.hold = 0;
ud->tcp_pcb->rcv_wnd = TCP_WND;
ud->tcp_pcb->flags |= TF_ACK_NOW;
tcp_recved(ud->tcp_pcb, 0);
}
return 0;
}

Expand Down