luaevent/src/luaevent.c

changeset 10
88ce07d62597
parent 9
1f3b72ba96c9
child 11
8339f6236a3c
--- a/luaevent/src/luaevent.c	Wed Jun 13 03:54:01 2007 +0000
+++ b/luaevent/src/luaevent.c	Wed Jun 13 04:32:12 2007 +0000
@@ -31,6 +31,7 @@
 		arg->L = NULL;
 		event_del(&arg->ev);
 		luaL_unref(L, LUA_REGISTRYINDEX, arg->callbackRef);
+		luaL_unref(L, LUA_REGISTRYINDEX, arg->objectRef);
 	}
 }
 
@@ -47,7 +48,6 @@
 	if(ret < 0) { /* Done, no need to setup event */
 		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);
 	}
@@ -80,7 +80,6 @@
 		return;
 	}
 	
-	printf("RET VAL: %i\n", ret);
 	if(event != ret)
 		setup_event(arg, fd, ret, 1);
 }
@@ -126,7 +125,8 @@
 	
 	arg->L = L;
 	arg->callbackRef = callbackRef;
-	
+	lua_pushvalue(L, -1);
+	arg->objectRef = luaL_ref(L, LUA_REGISTRYINDEX);
 	setup_event(arg, fd, event, 0);
 }
 /* Expected to be called at the beginning of the coro that uses it.. 

mercurial