From 63943567e9d16742afac41fa1c3e51d971776792 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Thu, 4 Nov 2010 22:33:33 +0100 Subject: [PATCH] don't fetch a RSS before the network frequency is elapsed currently the RSS-Thread is run over and over; we shouldn't stress our partrers to much, so we let the network poll frequency elaps before we try to poll the rss feed again. --- citadel/modules/rssclient/serv_rssclient.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/citadel/modules/rssclient/serv_rssclient.c b/citadel/modules/rssclient/serv_rssclient.c index 341e8b025..33e333513 100644 --- a/citadel/modules/rssclient/serv_rssclient.c +++ b/citadel/modules/rssclient/serv_rssclient.c @@ -64,6 +64,7 @@ struct rssnetcfg { char *rooms; time_t last_error_when; int ItemType; + time_t next_poll; }; #define RSS_UNSET (1<<0) @@ -1252,6 +1253,12 @@ void rss_do_fetching(rssnetcfg *Cfg) { const char *at; long len; + time_t now; + + now = time(NULL); + + if ((Cfg->next_poll != 0) && (now < Cfg->next_poll)) + return; memset(&ri, 0, sizeof(rss_item)); rssc.Item = &ri; rssc.Cfg = Cfg; @@ -1373,6 +1380,8 @@ shutdown: flush_rss_item(&ri); FreeStrBuf(&rssc.CData); FreeStrBuf(&rssc.Key); + + Cfg->next_poll = time(NULL) + config.c_net_freq; } @@ -1424,6 +1433,7 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data) /* Otherwise create a new client request */ if (use_this_rncptr == NULL) { rncptr = (rssnetcfg *) malloc(sizeof(rssnetcfg)); + memset(rncptr, 0, sizeof(rssnetcfg)); rncptr->ItemType = RSS_UNSET; if (rncptr != NULL) { rncptr->next = rnclist; -- 2.30.2