net module: hold/unhold support.

As per @djphoenix's work on the ESP8266 side.
This commit is contained in:
Johny Mattsson 2016-12-30 15:51:08 +11:00
parent 6bce18f9ac
commit 4ece8de4d9
1 changed files with 11 additions and 3 deletions

View File

@ -279,7 +279,7 @@ static err_t net_tcp_recv_cb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, er
}
if (post_net_recv (ud, p, 0, 0))
tcp_recved(tpcb, p->len);
tcp_recved(tpcb, ud->client.hold ? 0 : TCP_WND(tpcb));
return ERR_OK;
}
@ -632,7 +632,10 @@ 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;
}
return 0;
}
@ -641,7 +644,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->flags |= TF_ACK_NOW;
tcp_recved(ud->tcp_pcb, TCP_WND(ud->tcp_pcb));
}
return 0;
}