]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/network/serv_network.c
Somebody broke the build by forgetting to #include "threads.h" in some of
[citadel.git] / citadel / modules / network / serv_network.c
index 7b112abf2125b75dac912c0896bc4ed6e45ce217..66bd03692c20f4afc9b03be9233af8aaac42c64a 100644 (file)
@@ -64,6 +64,7 @@
 #include "clientsocket.h"
 #include "file_ops.h"
 #include "citadel_dirs.h"
+#include "threads.h"
 
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
@@ -518,7 +519,7 @@ void network_deliver_digest(SpoolControl *sc) {
        }
 
        /* Now submit the message */
-       valid = validate_recipients(recps);
+       valid = validate_recipients(recps, NULL, 0);
        free(recps);
        CtdlSubmitMsg(msg, valid, NULL);
        CtdlFreeMessage(msg);
@@ -565,7 +566,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
        }
 
        /* Now submit the message */
-       valid = validate_recipients(recps);
+       valid = validate_recipients(recps, NULL, 0);
        free(recps);
        CtdlSubmitMsg(msg, valid, NULL);
        free_recipients(valid);
@@ -734,7 +735,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                        }
                                        msg->cm_fields['R'] = strdup(nptr->name);
        
-                                       valid = validate_recipients(nptr->name);
+                                       valid = validate_recipients(nptr->name, NULL, 0);
                                        CtdlSubmitMsg(msg, valid, "");
                                        free_recipients(valid);
                                }
@@ -1060,27 +1061,29 @@ int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename)
        }
        return 1;
 }
-int is_recipient(SpoolControl *sc, char *Name)
+int is_recipient(SpoolControl *sc, const char *Name)
 {
        namelist *nptr;
+       size_t len;
 
+       len = strlen(Name);
        nptr = sc->listrecps;
        while (nptr != NULL) {
-               if (strcmp(Name, nptr->name)==0)
+               if (strncmp(Name, nptr->name, len)==0)
                        return 1;
                nptr = nptr->next;
        }
        /* Do the same for digestrecps */
        nptr = sc->digestrecps;
        while (nptr != NULL) {
-               if (strcmp(Name, nptr->name)==0)
+               if (strncmp(Name, nptr->name, len)==0)
                        return 1;
                nptr = nptr->next;
        }
        /* Do the same for participates */
        nptr = sc->participates;
        while (nptr != NULL) {
-               if (strcmp(Name, nptr->name)==0)
+               if (strncmp(Name, nptr->name, len)==0)
                        return 1;
                nptr = nptr->next;
        }
@@ -1403,7 +1406,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        free(oldpath);
 
        /* Now submit the message */
-       valid = validate_recipients(recipient);
+       valid = validate_recipients(recipient, NULL, 0);
        if (valid != NULL) if (valid->num_error != 0) {
                free_recipients(valid);
                valid = NULL;
@@ -1561,7 +1564,7 @@ void network_process_buffer(char *buffer, long size) {
 
        /* Otherwise, does it have a recipient?  If so, validate it... */
        else if (msg->cm_fields['R'] != NULL) {
-               recp = validate_recipients(msg->cm_fields['R']);
+               recp = validate_recipients(msg->cm_fields['R'], NULL, 0);
                if (recp != NULL) if (recp->num_error != 0) {
                        network_bounce(msg,
                                "A message you sent could not be delivered due to an invalid address.\n"
@@ -2043,7 +2046,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 +2057,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 +2066,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 +2138,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 +2215,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$";
 }