aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-01-16 04:21:17 +0000
committerMatthew Wild <mwild1@gmail.com>2012-01-16 04:21:17 +0000
commitbe5260d0af0b9fc3f10dce9813e362eda66eba51 (patch)
tree16a04d3a7b7c9edc985d54a5ce04a9372e5e4ae3
parentc7faf570a716329f0d0991cbb019a6fc5ed5b0de (diff)
downloadluaevent-prosody-be5260d0af0b9fc3f10dce9813e362eda66eba51.tar.gz
luaevent-prosody-be5260d0af0b9fc3f10dce9813e362eda66eba51.zip
event_callback.c: Check for event being destroyed during callback
-rw-r--r--src/event_callback.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/event_callback.c b/src/event_callback.c
index b1cdd02..1bf18ec 100644
--- a/src/event_callback.c
+++ b/src/event_callback.c
@@ -24,16 +24,15 @@ void luaevent_callback(int fd, short event, void* p) {
int ret;
double newTimeout = -1;
assert(cb);
- if(!cb->base) {
- /* Callback has been collected... die */
- /* TODO: What should really be done here... */
- return;
- }
+ if(!cb->base)
+ return; /* Event has already been collected + destroyed */
assert(cb->base->loop_L);
L = cb->base->loop_L;
lua_rawgeti(L, LUA_REGISTRYINDEX, cb->callbackRef);
lua_pushinteger(L, event);
lua_call(L, 1, 2);
+ if(!cb->base)
+ return; /* event was destroyed during callback */
ret = lua_tointeger(L, -2);
if(lua_isnumber(L, -1)) {
newTimeout = lua_tonumber(L, -1);