From 4ad6778dc1a9f03e18b5ec0d369c545c09390ab2 Mon Sep 17 00:00:00 2001 From: Thomas Harning Jr Date: Wed, 11 Apr 2012 23:51:53 -0400 Subject: [PATCH] base: fixes event_callback handling of no return values better --- CHANGELOG | 1 + src/event_callback.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f51fb63..7c28d69 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 0.4.1 - WIP + * Fixes event_callback handling to handle the no-return-value case better * Cleans up timertest formatting ====== 0.4.0 - 2012-04-10 diff --git a/src/event_callback.c b/src/event_callback.c index 5e022a8..0a7d25e 100644 --- a/src/event_callback.c +++ b/src/event_callback.c @@ -33,7 +33,10 @@ void luaevent_callback(int fd, short event, void* p) { lua_call(L, 1, 2); if(!cb->base) return; /* event was destroyed during callback */ - ret = lua_tointeger(L, -2); + /* If nothing is returned, re-use the old event value */ + ret = luaL_optinteger(L, -2, event); + /* Clone the old timeout value in case a new one wasn't set */ + memcpy(&new_tv, &cb->timeout, sizeof(new_tv)); if(lua_isnumber(L, -1)) { double newTimeout = lua_tonumber(L, -1); if(newTimeout > 0) { -- 2.11.4.GIT