Initialize cb for unsubscribe and unref it upon socket deletion. (#1305)

Thank you.
This commit is contained in:
Arnim Läuger 2016-05-21 14:25:16 +02:00 committed by Philip Gladstone
parent ab6c2c3924
commit 2bb6e407a3
1 changed files with 3 additions and 0 deletions

View File

@ -674,6 +674,7 @@ static int mqtt_socket_client( lua_State* L )
mud->cb_message_ref = LUA_NOREF;
mud->cb_suback_ref = LUA_NOREF;
mud->cb_unsuback_ref = LUA_NOREF;
mud->cb_puback_ref = LUA_NOREF;
mud->pesp_conn = NULL;
#ifdef CLIENT_SSL_ENABLE
@ -842,6 +843,8 @@ static int mqtt_delete( lua_State* L )
mud->cb_message_ref = LUA_NOREF;
luaL_unref(L, LUA_REGISTRYINDEX, mud->cb_suback_ref);
mud->cb_suback_ref = LUA_NOREF;
luaL_unref(L, LUA_REGISTRYINDEX, mud->cb_unsuback_ref);
mud->cb_unsuback_ref = LUA_NOREF;
luaL_unref(L, LUA_REGISTRYINDEX, mud->cb_puback_ref);
mud->cb_puback_ref = LUA_NOREF;
lua_gc(L, LUA_GCSTOP, 0);