From: Thomas Harning Jr Date: Thu, 12 Apr 2012 03:51:53 +0000 (-0400) Subject: base: fixes event_callback handling of no return values better X-Git-Tag: v0.4.1~1 X-Git-Url: https://repo.or.cz/w/luaevent.git/commitdiff_plain/4ad6778dc1a9f03e18b5ec0d369c545c09390ab2 base: fixes event_callback handling of no return values better --- 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) {