[Reconnoiter-devel] [reconnoiter commit] r840 - trunk/src/modules

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Wed Sep 16 00:12:39 EDT 2009


Author: jesus
Date: 2009-09-16 00:12:39 -0400 (Wed, 16 Sep 2009)
New Revision: 840

Modified:
   trunk/src/modules/lua.c
   trunk/src/modules/lua_noit.c
   trunk/src/modules/lua_noit.h
Log:
fix was small (strdup, stupid) and some other cleanup, fixes #179

Modified: trunk/src/modules/lua.c
===================================================================
--- trunk/src/modules/lua.c	2009-09-16 03:55:29 UTC (rev 839)
+++ trunk/src/modules/lua.c	2009-09-16 04:12:39 UTC (rev 840)
@@ -451,6 +451,8 @@
   lua_State *L;
   lua_module_closure_t *lmc;
 
+  noit_lua_init();
+
   lmc = noit_image_get_userdata(i);
   L = lmc->lua_state;
   lua_getglobal(L, "require");
@@ -592,6 +594,7 @@
 int
 noit_lua_resume(noit_lua_check_info_t *ci, int nargs) {
   int result = -1, base;
+  noit_module_t *self;
   noit_check_t *check;
   check = ci->check;
 
@@ -618,16 +621,18 @@
           err = lua_tostring(ci->coro_state, base);
           if(err) {
             free(ci->current.status);
-            ci->current.status = (char *)err;
+            ci->current.status = strdup(err);
           }
         }
       }
       break;
   }
+
+  self = ci->self;
+  check = ci->check;
   cancel_coro(ci);
-
-  noit_lua_log_results(ci->self, ci->check);
-  noit_lua_module_cleanup(ci->self, ci->check);
+  noit_lua_log_results(self, check);
+  noit_lua_module_cleanup(self, check);
   ci = NULL; /* we freed it... explode if someone uses it before we return */
   check->flags &= ~NP_RUNNING;
 
@@ -637,6 +642,7 @@
 static int
 noit_lua_check_timeout(eventer_t e, int mask, void *closure,
                        struct timeval *now) {
+  noit_module_t *self;
   noit_check_t *check;
   struct nl_intcl *int_cl = closure;
   noit_lua_check_info_t *ci = int_cl->ci;
@@ -644,6 +650,10 @@
   noitL(nldeb, "lua: %p ->check_timeout\n", ci->coro_state);
   ci->timed_out = 1;
   noit_lua_check_deregister_event(ci, e, 0);
+
+  self = ci->self;
+  check = ci->check;
+
   if(ci->coro_state) {
     /* Our coro is still "in-flight". To fix this we will unreference
      * it, garbage collect it and then ensure that it failes a resume
@@ -651,8 +661,8 @@
     cancel_coro(ci);
   }
 
-  noit_lua_log_results(ci->self, ci->check);
-  noit_lua_module_cleanup(ci->self, ci->check);
+  noit_lua_log_results(self, check);
+  noit_lua_module_cleanup(self, check);
   check->flags &= ~NP_RUNNING;
 
   if(int_cl->free) int_cl->free(int_cl);
@@ -811,8 +821,8 @@
 }
 static int
 noit_lua_loader_onload(noit_image_t *self) {
-  nlerr = noit_log_stream_find("error/serf");
-  nldeb = noit_log_stream_find("debug/serf");
+  nlerr = noit_log_stream_find("error/lua");
+  nldeb = noit_log_stream_find("debug/lua");
   if(!nlerr) nlerr = noit_stderr;
   if(!nldeb) nldeb = noit_debug;
   return 0;

Modified: trunk/src/modules/lua_noit.c
===================================================================
--- trunk/src/modules/lua_noit.c	2009-09-16 03:55:29 UTC (rev 839)
+++ trunk/src/modules/lua_noit.c	2009-09-16 04:12:39 UTC (rev 840)
@@ -667,3 +667,14 @@
   luaL_register(L, "noit", noitlib);
   return 0;
 }
+
+void noit_lua_init() {
+  eventer_name_callback("lua/sleep", nl_sleep_complete);
+  eventer_name_callback("lua/socket_read",
+                        noit_lua_socket_read_complete);
+  eventer_name_callback("lua/socket_write",
+                        noit_lua_socket_write_complete);
+  eventer_name_callback("lua/socket_connect",
+                        noit_lua_socket_connect_complete);
+  eventer_name_callback("lua/ssl_upgrade", noit_lua_ssl_upgrade);
+}

Modified: trunk/src/modules/lua_noit.h
===================================================================
--- trunk/src/modules/lua_noit.h	2009-09-16 03:55:29 UTC (rev 839)
+++ trunk/src/modules/lua_noit.h	2009-09-16 04:12:39 UTC (rev 840)
@@ -92,6 +92,7 @@
   lua_State *L;
 };
 
+void noit_lua_init();
 int luaopen_noit(lua_State *L);
 noit_lua_check_info_t *get_ci(lua_State *L);
 int noit_lua_yield(noit_lua_check_info_t *ci, int nargs);



More information about the Reconnoiter-devel mailing list