]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/rssclient/serv_rssclient.c
More logging for rssclient and pop3client holdoff and concurrency checks
[citadel.git] / citadel / modules / rssclient / serv_rssclient.c
index 44f779f44be0b56c61b5783e6353271c914cefb9..bbf3c0c78431c2693773fef2f620453ce76d328b 100644 (file)
@@ -5,17 +5,11 @@
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
- * 
- * 
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
  * GNU General Public License for more details.
- *
- * 
- * 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
  */
 
 #include <stdlib.h>
@@ -69,6 +63,7 @@ HashList *RSSQueueRooms = NULL; /* rss_room_counter */
 HashList *RSSFetchUrls = NULL; /*->rss_aggregator;->RefCount access locked*/
 
 eNextState RSSAggregator_Terminate(AsyncIO *IO);
+eNextState RSSAggregator_TerminateDB(AsyncIO *IO);
 eNextState RSSAggregator_ShutdownAbort(AsyncIO *IO);
 struct CitContext rss_CC;
 
@@ -180,6 +175,17 @@ eNextState RSSAggregator_Terminate(AsyncIO *IO)
        return eAbort;
 }
 
+eNextState RSSAggregator_TerminateDB(AsyncIO *IO)
+{
+       rss_aggregator *RSSAggr = (rss_aggregator *)IO->Data;
+
+       EVM_syslog(LOG_DEBUG, "RSS: Terminating.\n");
+
+
+       UnlinkRSSAggregator(RSSAggr);
+       return eAbort;
+}
+
 eNextState RSSAggregator_ShutdownAbort(AsyncIO *IO)
 {
        const char *pUrl;
@@ -294,6 +300,7 @@ int rss_do_fetching(rss_aggregator *Cfg)
                               "Citadel RSS Client",
                               RSSAggregator_ParseReply,
                               RSSAggregator_Terminate,
+                              RSSAggregator_TerminateDB,
                               RSSAggregator_ShutdownAbort))
        {
                syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
@@ -495,6 +502,11 @@ void rssclient_scan(void) {
 
        /* Run no more than once every 15 minutes. */
        if ((now - last_run) < 900) {
+               syslog(LOG_DEBUG,
+                       "rssclient: polling interval not yet reached; last run was %ldm%lds ago",
+                       ((now - last_run) / 60),
+                       ((now - last_run) % 60)
+               );
                return;
        }
 
@@ -505,8 +517,14 @@ void rssclient_scan(void) {
         * with a static variable instead.
         */
 
-       if ((GetCount(RSSQueueRooms) > 0) || (GetCount(RSSFetchUrls) > 0))
+       if ((GetCount(RSSQueueRooms) > 0) || (GetCount(RSSFetchUrls) > 0)) {
+               syslog(LOG_DEBUG,
+                       "rssclient: concurrency check failed; %d rooms and %d url's are queued",
+                       GetCount(RSSQueueRooms),
+                       GetCount(RSSFetchUrls)
+               );
                return;
+       }
 
        become_session(&rss_CC);
        syslog(LOG_DEBUG, "rssclient started\n");
@@ -547,7 +565,7 @@ CTDL_MODULE_INIT(rssclient)
                RSSFetchUrls = NewHash(1, NULL);
                syslog(LOG_INFO, "%s\n", curl_version());
                CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
-               CtdlRegisterCleanupHook(rss_cleanup);
+               CtdlRegisterEVCleanupHook(rss_cleanup);
        }
        return "rssclient";
 }