Commit 3e60fa8f authored by Johny Mattsson's avatar Johny Mattsson Committed by Marcel Stör
Browse files

Fix data loss in TCP streams. (#2097)

* Fix data loss in TCP streams.

* Factored out the UDP extra args handling.
parent 119835bf
...@@ -202,20 +202,29 @@ static void net_recv_cb(lnet_userdata *ud, struct pbuf *p, ip_addr_t *addr, u16_ ...@@ -202,20 +202,29 @@ static void net_recv_cb(lnet_userdata *ud, struct pbuf *p, ip_addr_t *addr, u16_
pbuf_free(p); pbuf_free(p);
return; return;
} }
lua_State *L = lua_getstate();
int num_args = 2; 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->client.cb_receive_ref);
lua_rawgeti(L, LUA_REGISTRYINDEX, ud->self_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) { 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_pushinteger(L, port);
lua_pushstring(L, iptmp); lua_pushstring(L, iptmp);
} }
lua_call(L, num_args, 0); lua_call(L, num_args, 0);
pp = pp->next;
}
pbuf_free(p); pbuf_free(p);
} }
......
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