EXTREMELY EXPERIMENTAL
authorDave West <davew@uncensored.citadel.org>
Fri, 7 Dec 2007 00:15:12 +0000 (00:15 +0000)
committerDave West <davew@uncensored.citadel.org>
Fri, 7 Dec 2007 00:15:12 +0000 (00:15 +0000)
rss client and network modules are now run as scheduled threads.

citadel/modules/network/serv_network.c
citadel/modules/rssclient/serv_rssclient.c

index 7b112abf2125b75dac912c0896bc4ed6e45ce217..5d55b2336ff2d5d794a9c3f30192ec6d9027eab6 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;
@@ -2062,7 +2062,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 +2134,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 +2211,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$";
 }
index c9461a673934ed8d45ad0231aa3abd9b3e36ee1d..4ef2cfb321ec1761b9748d12d24f09dbd3834c69 100644 (file)
@@ -580,17 +580,18 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data)
 /*
  * Scan for rooms that have RSS client requests configured
  */
-void rssclient_scan(void) {
+void *rssclient_scan(void *args) {
        static time_t last_run = 0L;
        static int doing_rssclient = 0;
        struct rssnetcfg *rptr = NULL;
 
+       CtdlThreadAllocTSD();
        /*
         * Run RSS client no more frequently than once every n seconds
         */
-       if ( (time(NULL) - last_run) < config.c_net_freq ) {
-               return;
-       }
+//     if ( (time(NULL) - last_run) < config.c_net_freq ) {
+//             return;
+//     }
 
        /*
         * This is a simple concurrency check to make sure only one rssclient run
@@ -598,7 +599,7 @@ void rssclient_scan(void) {
         * don't really require extremely fine granularity here, we'll do it
         * with a static variable instead.
         */
-       if (doing_rssclient) return;
+       if (doing_rssclient) return NULL;
        doing_rssclient = 1;
 
        lprintf(CTDL_DEBUG, "rssclient started\n");
@@ -615,6 +616,8 @@ void rssclient_scan(void) {
        lprintf(CTDL_DEBUG, "rssclient ended\n");
        last_run = time(NULL);
        doing_rssclient = 0;
+       CtdlThreadSchedule ("RSS Client", CTDLTHREAD_BIGSTACK, rssclient_scan, NULL, last_run + config.c_net_freq);
+       return NULL;
 }
 
 
@@ -622,10 +625,11 @@ void rssclient_scan(void) {
 
 CTDL_MODULE_INIT(rssclient)
 {
-       if (!threading)
+       if (threading)
        {
 #ifdef HAVE_EXPAT
-               CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
+//             CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
+               CtdlThreadSchedule ("RSS Client", CTDLTHREAD_BIGSTACK, rssclient_scan, NULL, 0);
 #else
                lprintf(CTDL_INFO, "This server is missing the Expat XML parser.  RSS client will be disabled.\n");
 #endif