From: root Date: Thu, 26 Apr 2012 20:27:50 +0000 (+0200) Subject: RSS-Client: add missing locks X-Git-Tag: v8.11~65 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=e0b813f4802ce167188d501761ec6648edcc5649;hp=00a46dcdfd9920d3966274aebc4e50b4c88eb549;p=citadel.git RSS-Client: add missing locks --- diff --git a/citadel/modules/rssclient/serv_rssclient.c b/citadel/modules/rssclient/serv_rssclient.c index bbf3c0c78..68f04ab75 100644 --- a/citadel/modules/rssclient/serv_rssclient.c +++ b/citadel/modules/rssclient/serv_rssclient.c @@ -124,6 +124,7 @@ void UnlinkRSSAggregator(rss_aggregator *Cfg) { HashPos *At; + pthread_mutex_lock(&RSSQueueMutex); UnlinkRooms(Cfg); At = GetNewHashPos(RSSFetchUrls, 0); @@ -133,6 +134,7 @@ void UnlinkRSSAggregator(rss_aggregator *Cfg) } DeleteHashPos(&At); last_run = time(NULL); + pthread_mutex_unlock(&RSSQueueMutex); } void DeleteRssCfg(void *vptr) @@ -493,6 +495,7 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data) * Scan for rooms that have RSS client requests configured */ void rssclient_scan(void) { + int RSSRoomCount, RSSCount; rss_aggregator *rptr = NULL; void *vrptr = NULL; HashPos *it; @@ -512,17 +515,18 @@ void rssclient_scan(void) { /* * This is a simple concurrency check to make sure only one rssclient - * 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. + * run is done at a time. */ + pthread_mutex_lock(&RSSQueueMutex); + RSSCount = GetCount(RSSFetchUrls); + RSSRoomCount = GetCount(RSSQueueRooms); + pthread_mutex_unlock(&RSSQueueMutex); - if ((GetCount(RSSQueueRooms) > 0) || (GetCount(RSSFetchUrls) > 0)) { + if ((RSSRoomCount > 0) || (RSSCount > 0)) { syslog(LOG_DEBUG, - "rssclient: concurrency check failed; %d rooms and %d url's are queued", - GetCount(RSSQueueRooms), - GetCount(RSSFetchUrls) - ); + "rssclient: concurrency check failed; %d rooms and %d url's are queued", + RSSRoomCount, RSSCount + ); return; }