Skip to content

Commit

Permalink
base: fixes event_callback handling of no return values better
Browse files Browse the repository at this point in the history
  • Loading branch information
harningt committed Apr 12, 2012
1 parent 1a1c026 commit 4ad6778
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions 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
Expand Down
5 changes: 4 additions & 1 deletion src/event_callback.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 4ad6778

Please sign in to comment.