libubus.h: add ubus_auto_shutdown()
[project/ubus.git] / lua / ubus.c
index a48fb7d..86e34b7 100644 (file)
@@ -302,8 +302,9 @@ ubus_method_handler(struct ubus_context *ctx, struct ubus_object *obj,
                lua_call(state, 2, 1);
                if (lua_isnumber(state, -1))
                        rv = lua_tonumber(state, -1);
-       } else
-               lua_pop(state, 1);
+       }
+
+       lua_pop(state, 1);
 
        return rv;
 }
@@ -597,10 +598,13 @@ ubus_event_handler(struct ubus_context *ctx, struct ubus_event_handler *ev,
 
        lua_getglobal(state, "__ubus_cb_event");
        lua_rawgeti(state, -1, listener->r);
+       lua_remove(state, -2);
 
        if (lua_isfunction(state, -1)) {
                ubus_lua_parse_blob_array(state, blob_data(msg), blob_len(msg), true);
                lua_call(state, 1, 0);
+       } else {
+               lua_pop(state, 1);
        }
 }