Fix data loss in TCP streams. (#2097)
* Fix data loss in TCP streams. * Factored out the UDP extra args handling.
This commit is contained in:
parent
119835bf30
commit
3e60fa8f60
|
@ -202,20 +202,29 @@ static void net_recv_cb(lnet_userdata *ud, struct pbuf *p, ip_addr_t *addr, u16_
|
|||
pbuf_free(p);
|
||||
return;
|
||||
}
|
||||
lua_State *L = lua_getstate();
|
||||
|
||||
int num_args = 2;
|
||||
char iptmp[16] = { 0, };
|
||||
if (ud->type == TYPE_UDP_SOCKET)
|
||||
{
|
||||
num_args += 2;
|
||||
ets_sprintf(iptmp, IPSTR, IP2STR(&addr->addr));
|
||||
}
|
||||
|
||||
lua_State *L = lua_getstate();
|
||||
struct pbuf *pp = p;
|
||||
while (pp)
|
||||
{
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, ud->client.cb_receive_ref);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, ud->self_ref);
|
||||
lua_pushlstring(L, p->payload, p->len);
|
||||
lua_pushlstring(L, pp->payload, pp->len);
|
||||
if (ud->type == TYPE_UDP_SOCKET) {
|
||||
num_args += 2;
|
||||
char iptmp[16];
|
||||
bzero(iptmp, 16);
|
||||
ets_sprintf(iptmp, IPSTR, IP2STR(&addr->addr));
|
||||
lua_pushinteger(L, port);
|
||||
lua_pushstring(L, iptmp);
|
||||
}
|
||||
lua_call(L, num_args, 0);
|
||||
pp = pp->next;
|
||||
}
|
||||
pbuf_free(p);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue