]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/network/serv_network.c
Hunting a bug in scheduled threads that caused a segflt. Got it and
[citadel.git] / citadel / modules / network / serv_network.c
index 7b112abf2125b75dac912c0896bc4ed6e45ce217..c685ec4d1aa69d192ebba481e6d3daad1afa4aeb 100644 (file)
@@ -2043,7 +2043,7 @@ void create_spool_dirs(void) {
  * 
  * Run through the rooms doing various types of network stuff.
  */
-void network_do_queue(void) {
+void *network_do_queue(void *args) {
        static time_t last_run = 0L;
        struct RoomProcList *ptr;
        int full_processing = 1;
@@ -2054,6 +2054,7 @@ void network_do_queue(void) {
         */
        if ( (time(NULL) - last_run) < config.c_net_freq ) {
                full_processing = 0;
+               CtdlLogPrintf(CTDL_DEBUG, "Network full processing in %ld seconds.\n", config.c_net_freq - (time(NULL)- last_run));
        }
 
        /*
@@ -2062,7 +2063,7 @@ void network_do_queue(void) {
         * don't really require extremely fine granularity here, we'll do it
         * with a static variable instead.
         */
-       if (doing_queue) return;
+       if (doing_queue) return NULL;
        doing_queue = 1;
 
        /* Load the IGnet Configuration into memory */
@@ -2134,6 +2135,8 @@ void network_do_queue(void) {
        }
 
        doing_queue = 0;
+       CtdlThreadSchedule("IGnet Network", CTDLTHREAD_BIGSTACK, network_do_queue, NULL, time(NULL) + 60);
+       return NULL;
 }
 
 
@@ -2209,11 +2212,12 @@ CTDL_MODULE_INIT(network)
                CtdlRegisterProtoHook(cmd_snet, "SNET", "Set network config");
                CtdlRegisterProtoHook(cmd_netp, "NETP", "Identify as network poller");
                CtdlRegisterProtoHook(cmd_nsyn, "NSYN", "Synchronize room to node");
-               CtdlRegisterSessionHook(network_do_queue, EVT_TIMER);
+//             CtdlRegisterSessionHook(network_do_queue, EVT_TIMER);
                CtdlRegisterRoomHook(network_room_handler);
                CtdlRegisterCleanupHook(destroy_network_queue_room);
        }
-
+       else
+               CtdlThreadSchedule("IGnet Network", CTDLTHREAD_BIGSTACK, network_do_queue, NULL, 0);
        /* return our Subversion id for the Log */
        return "$Id$";
 }