POP3 client is now in development, add -DPOP3_AGGREGATION to enable
authorArt Cancro <ajc@citadel.org>
Mon, 17 Sep 2007 16:18:50 +0000 (16:18 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 17 Sep 2007 16:18:50 +0000 (16:18 +0000)
citadel/modules/pop3client/serv_pop3client.c

index e260e34daf4317dc3af812849e16c9cdb88f4d54..f6513fc7e38d37795c3cb58be3b181200d3b0aff 100644 (file)
 #include "server.h"
 #include "citserver.h"
 #include "support.h"
-#include "user_ops.h"
-#include "md5.h"
+#include "config.h"
 #include "tools.h"
+#include "room_ops.h"
 
 
 #include "ctdl_module.h"
 
 
-/*
+#ifdef POP3_AGGREGATION
+
+void pop3client_do_room(struct ctdlroom *qrbuf, void *data)
+{
+
+       lprintf(CTDL_DEBUG, "POP3 aggregation for <%s>\n", qrbuf->QRname);
+
+}
+
+
 void pop3client_scan(void) {
+       static time_t last_run = 0L;
+       static int doing_pop3client = 0;
+
+       /*
+        * Run POP3 aggregation no more frequently than once every n seconds
+        */
+       if ( (time(NULL) - last_run) < config.c_net_freq ) {
+               return;
+       }
+
+       /*
+        * This is a simple concurrency check to make sure only one pop3client run
+        * is done at a time.  We could do this with a mutex, but since we
+        * don't really require extremely fine granularity here, we'll do it
+        * with a static variable instead.
+        */
+       if (doing_pop3client) return;
+       doing_pop3client = 1;
+
        lprintf(CTDL_DEBUG, "pop3client started\n");
+       ForEachRoom(pop3client_do_room, NULL);
        lprintf(CTDL_DEBUG, "pop3client ended\n");
+
+       doing_pop3client = 0;
 }
-*/
 
+#endif
 
 CTDL_MODULE_INIT(pop3client)
 {
-       /* CtdlRegisterSessionHook(pop3client_scan, EVT_TIMER); */
+#ifdef POP3_AGGREGATION
+       CtdlRegisterSessionHook(pop3client_scan, EVT_TIMER);
+#endif
 
        /* return our Subversion id for the Log */
         return "$Id:  $";