diff options
author | Thomas Harning Jr <harningt@gmail.com> | 2007-06-13 03:54:01 +0000 |
---|---|---|
committer | Thomas Harning Jr <harningt@gmail.com> | 2007-06-13 03:54:01 +0000 |
commit | a309c7952c6ae1b9ad9c9c0c0d895e1ad969cb95 (patch) | |
tree | 569f9eaa8333752a562b124fd27a3512d85337f1 | |
parent | 15c4477d99a84a206453b538b58f20bfc7fdc70d (diff) | |
download | luaevent-prosody-a309c7952c6ae1b9ad9c9c0c0d895e1ad969cb95.tar.gz luaevent-prosody-a309c7952c6ae1b9ad9c9c0c0d895e1ad969cb95.zip |
Fixed up return-value handling.
-rw-r--r-- | luaevent/src/luaevent.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/luaevent/src/luaevent.c b/luaevent/src/luaevent.c index 261b2de..8539a99 100644 --- a/luaevent/src/luaevent.c +++ b/luaevent/src/luaevent.c @@ -39,18 +39,19 @@ static int call_callback_function(lua_State* L, int argCount) { if(lua_pcall(L, argCount, 1, 0) || !(lua_isnil(L, -1) || lua_isnumber(L, -1))) { printf("ERROR IN INIT: %s\n", lua_tostring(L, -1)); lua_pop(L, 1); - return 0; + return -1; } /* Lua_isnil returns 1 if the value is nil... */ ret = lua_tointeger(L, -1) | -lua_isnil(L, -1); lua_pop(L, 1); if(ret < 0) { /* Done, no need to setup event */ - return 0; + return -1; } + printf("WAITING FOR: %i RED: %i WR:%i\n", ret, EV_READ, EV_WRITE); if(ret != EV_READ && ret != EV_WRITE) { printf("BAD RET_VAL IN INIT: %i\n", ret); } - return 1; + return ret; } static void luaevent_callback(int fd, short event, void* p); @@ -74,7 +75,7 @@ static void luaevent_callback(int fd, short event, void* p) { lua_rawgeti(L, LUA_REGISTRYINDEX, arg->callbackRef); lua_pushinteger(L, event); - if(0 == call_callback_function(L, 1)) { + if(-1 == (ret = call_callback_function(L, 1))) { freeCallbackArgs(arg); return; } @@ -142,7 +143,7 @@ static int luaevent_addevent(lua_State* L) { lua_pushvalue(L, 2); callbackRef = luaL_ref(L, LUA_REGISTRYINDEX); /* Call the callback with all arguments after it to get the loop primed.. */ - if(0 == call_callback_function(L, top - 2)) { + if(-1 == (ret = call_callback_function(L, top - 2))) { luaL_unref(L, LUA_REGISTRYINDEX, callbackRef); return 0; } |