]> code.citadel.org Git - citadel.git/commitdiff
* serv_network.c: use a stat() call to determine the mtime of spoolin, and
authorArt Cancro <ajc@citadel.org>
Sun, 18 Sep 2005 17:50:05 +0000 (17:50 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 18 Sep 2005 17:50:05 +0000 (17:50 +0000)
  skip the scan if it hasn't been touched since the last time we looked.
* serv_network.c: don't create network/systems/ directory.  We haven't used
  that in ages.
* serv_network.c: only attempt to create directories at startup, not at
  every queue run.  Also, chown() them to the citadel user.

citadel/ChangeLog
citadel/serv_network.c

index cd103ce8ce8477052eae9b8d269817ac8f073dc8..71dbb7a214318db86979c5667fd16a655b96111d 100644 (file)
@@ -1,4 +1,12 @@
 $Log$
+Revision 655.8  2005/09/18 17:50:05  ajc
+* serv_network.c: use a stat() call to determine the mtime of spoolin, and
+  skip the scan if it hasn't been touched since the last time we looked.
+* serv_network.c: don't create network/systems/ directory.  We haven't used
+  that in ages.
+* serv_network.c: only attempt to create directories at startup, not at
+  every queue run.  Also, chown() them to the citadel user.
+
 Revision 655.7  2005/09/16 20:40:44  ajc
 * CC: support for message creation, and IMAP.  Not tested.
 
@@ -7135,4 +7143,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 99b18724d3bf0988eed4617fd69365f953c7d459..84a2c48aef5981a5dc17084eeafed67977db6fbf 100644 (file)
@@ -4,7 +4,7 @@
  * This module handles shared rooms, inter-Citadel mail, and outbound
  * mailing list processing.
  *
- * Copyright (C) 2000-2002 by Art Cancro and others.
+ * Copyright (C) 2000-2005 by Art Cancro and others.
  * This code is released under the terms of the GNU General Public License.
  *
  * ** NOTE **   A word on the S_NETCONFIGS semaphore:
@@ -70,7 +70,7 @@
 #include "snprintf.h"
 #endif
 
-/* Nonzero while we are doing outbound network processing */
+/* Nonzero while we are doing network processing */
 static int doing_queue = 0;
 
 /*
@@ -1492,15 +1492,33 @@ void network_process_file(char *filename) {
 void network_do_spoolin(void) {
        DIR *dp;
        struct dirent *d;
+       struct stat statbuf;
        char filename[256];
-
-       dp = opendir(
+       static time_t last_spoolin_mtime = 0L;
+       const char *spoolin_dirname = 
 #ifndef HAVE_SPOOL_DIR
                                 "."
 #else
                                 SPOOL_DIR
 #endif /* HAVE_SPOOL_DIR */
-                                "/network/spoolin");
+                                "/network/spoolin";
+
+       /*
+        * Check the spoolin directory's modification time.  If it hasn't
+        * been touched, we don't need to scan it.
+        */
+       if (stat(spoolin_dirname, &statbuf)) return;
+       if (statbuf.st_mtime == last_spoolin_mtime) {
+               lprintf(CTDL_DEBUG, "network: nothing in inbound queue\n");
+               return;
+       }
+       last_spoolin_mtime = statbuf.st_mtime;
+       lprintf(CTDL_DEBUG, "network: processing inbound queue\n");
+
+       /*
+        * Ok, there's something interesting in there, so scan it.
+        */
+       dp = opendir(spoolin_dirname);
        if (dp == NULL) return;
 
        while (d = readdir(dp), d != NULL) {
@@ -1825,14 +1843,18 @@ void network_poll_other_citadel_nodes(int full_poll) {
 void create_spool_dirs(void) {
 #ifndef HAVE_SPOOL_DIR
        mkdir("./network", 0700);
-       mkdir("./network/systems", 0700);
+       chown("./network", CTDLUID, (-1));
        mkdir("./network/spoolin", 0700);
+       chown("./network/spoolin", CTDLUID, (-1));
        mkdir("./network/spoolout", 0700);
+       chown("./network/spoolout", CTDLUID, (-1));
 #else
        mkdir(SPOOL_DIR "/network", 0700);
-       mkdir(SPOOL_DIR "/network/systems", 0700);
+       chown(SPOOL_DIR "./network", CTDLUID, (-1));
        mkdir(SPOOL_DIR "/network/spoolin", 0700);
+       chown(SPOOL_DIR "./network/spoolin", CTDLUID, (-1));
        mkdir(SPOOL_DIR "/network/spoolout", 0700);
+       chown(SPOOL_DIR "./network/spoolout", CTDLUID, (-1));
 #endif /* HAVE_SPOOL_DIR */
 }
 
@@ -1858,8 +1880,6 @@ void network_do_queue(void) {
                full_processing = 0;
        }
 
-       create_spool_dirs();
-
        /*
         * This is a simple concurrency check to make sure only one queue run
         * is done at a time.  We could do this with a mutex, but since we
@@ -1901,7 +1921,7 @@ void network_do_queue(void) {
                }
        }
 
-       lprintf(CTDL_DEBUG, "network: processing inbound queue\n");
+       /* If there is anything in the inbound queue, process it */
        network_do_spoolin();
 
        /* Save the network map back to disk */