# HG changeset patch # User Thomas Harning Jr # Date 1181706841 0 # Node ID 1f3b72ba96c961fba4c905ee700b174cbf643b32 # Parent b134613f6303b10a18662c32147de40a40c5e03e Fixed up return-value handling. diff -r b134613f6303 -r 1f3b72ba96c9 luaevent/src/luaevent.c --- a/luaevent/src/luaevent.c Wed Jun 13 03:29:11 2007 +0000 +++ b/luaevent/src/luaevent.c Wed Jun 13 03:54:01 2007 +0000 @@ -39,18 +39,19 @@ 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 @@ 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 @@ 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; }