From 7ded3960eb72c9cc7095353ef8c02bd59ed52cd4 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Sat, 20 Oct 2018 22:58:57 +0200 Subject: [PATCH] fix net hold/unhold --- components/modules/net.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/components/modules/net.c b/components/modules/net.c index 05c32455..ebcb95d3 100644 --- a/components/modules/net.c +++ b/components/modules/net.c @@ -678,8 +678,11 @@ int net_hold( lua_State *L ) { return luaL_error(L, "invalid user data"); if (!ud->client.hold && ud->netconn) { - ud->client.hold = 1; - ud->client.num_held = 0; + if (ud->client.hold == 0) + { + ud->client.hold = 1; + ud->client.num_held = 0; + } } return 0; } @@ -691,8 +694,12 @@ int net_unhold( lua_State *L ) { return luaL_error(L, "invalid user data"); if (ud->client.hold && ud->netconn) { - ud->client.hold = 0; - netconn_recved(ud->netconn, ud->client.num_held); + if (ud->client.hold != 0) + { + ud->client.hold = 0; + netconn_recved(ud->netconn, ud->client.num_held); + ud->client.num_held = 0; + } } return 0; } @@ -1130,7 +1137,6 @@ static void lrecv_cb (lua_State *L, lnet_userdata *ud) { if (ud->type == TYPE_TCP_CLIENT) { if (ud->client.hold) { - netconn_recved(ud->netconn, 0); ud->client.num_held += len; } else { netconn_recved(ud->netconn, len);