before removing an entry from an hash, revalidate whether we actualy found it
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 21 Nov 2011 18:54:35 +0000 (19:54 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 21 Nov 2011 18:54:35 +0000 (19:54 +0100)
citadel/modules/pop3client/serv_pop3client.c
citadel/modules/rssclient/serv_rssclient.c
citadel/modules/smtp/serv_smtpqueue.c

index 8bd39899c5037f5ff31a5791e776fb68f755ddca..9e9ac87d0baa91dded211f6f9f0011d461aa5fd8 100644 (file)
@@ -165,8 +165,8 @@ eNextState FinalizePOP3AggrRun(AsyncIO *IO)
        It = GetNewHashPos(POP3FetchUrls, 0);
        pthread_mutex_lock(&POP3QueueMutex);
        {
-               GetHashPosFromKey(POP3FetchUrls, SKEY(cptr->Url), It);
-               DeleteEntryFromHash(POP3FetchUrls, It);
+               if (GetHashPosFromKey(POP3FetchUrls, SKEY(cptr->Url), It))
+                       DeleteEntryFromHash(POP3FetchUrls, It);
        }
        pthread_mutex_unlock(&POP3QueueMutex);
        DeleteHashPos(&It);
index 79ba35c6058fdadd06a591a3f86f21b09080230f..72717359a6fc9f1fdb8aa0fc08eb6b4156e8db78 100644 (file)
@@ -101,14 +101,16 @@ void DeleteRoomReference(long QRnumber)
 
        At = GetNewHashPos(RSSQueueRooms, 0);
 
-       GetHashPosFromKey(RSSQueueRooms, LKEY(QRnumber), At);
-       GetHashPos(RSSQueueRooms, At, &HKLen, &HK, &vData);
-       if (vData != NULL)
+       if (GetHashPosFromKey(RSSQueueRooms, LKEY(QRnumber), At))
        {
-               pRoomC = (rss_room_counter *) vData;
-               pRoomC->count --;
-               if (pRoomC->count == 0)
-                       DeleteEntryFromHash(RSSQueueRooms, At);
+               GetHashPos(RSSQueueRooms, At, &HKLen, &HK, &vData);
+               if (vData != NULL)
+               {
+                       pRoomC = (rss_room_counter *) vData;
+                       pRoomC->count --;
+                       if (pRoomC->count == 0)
+                               DeleteEntryFromHash(RSSQueueRooms, At);
+               }
        }
        DeleteHashPos(&At);
 }
@@ -146,7 +148,7 @@ void UnlinkRSSAggregator(rss_aggregator *Cfg)
        UnlinkRooms(Cfg);
 
        At = GetNewHashPos(RSSFetchUrls, 0);
-       if (GetHashPosFromKey(RSSFetchUrls, SKEY(Cfg->Url), At) == 0)
+       if (GetHashPosFromKey(RSSFetchUrls, SKEY(Cfg->Url), At))
        {
                DeleteEntryFromHash(RSSFetchUrls, At);
        }
index 5f22ee6fbd2bfc3088b24fc3ada8b7bd4521facb..2197acf63dd34d36bd95e6f54666f5fb0c8a9e02 100644 (file)
@@ -671,8 +671,8 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                It = GetNewHashPos(MyQItem->MailQEntries, 0);
                pthread_mutex_lock(&ActiveQItemsLock);
                {
-                       GetHashPosFromKey(ActiveQItems, LKEY(MyQItem->MessageID), It);
-                       DeleteEntryFromHash(ActiveQItems, It);
+                       if (GetHashPosFromKey(ActiveQItems, LKEY(MyQItem->MessageID), It))
+                               DeleteEntryFromHash(ActiveQItems, It);
                }
                pthread_mutex_unlock(&ActiveQItemsLock);
                ////FreeQueItem(&MyQItem); TODO: DeleteEntryFromHash frees this?
@@ -688,8 +688,8 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                It = GetNewHashPos(MyQItem->MailQEntries, 0);
                pthread_mutex_lock(&ActiveQItemsLock);
                {
-                       GetHashPosFromKey(ActiveQItems, LKEY(MyQItem->MessageID), It);
-                       DeleteEntryFromHash(ActiveQItems, It);
+                       if (GetHashPosFromKey(ActiveQItems, LKEY(MyQItem->MessageID), It))
+                               DeleteEntryFromHash(ActiveQItems, It);
                }
                pthread_mutex_unlock(&ActiveQItemsLock);
                DeleteHashPos(&It);