protect access to the counter by mutex, else we might get race conditions.
[citadel.git] / citadel / modules / smtp / serv_smtpqueue.c
index 6b46164c611e399605d040268bc0f6116c26d97a..6ce5600728ecde9616b4309d292c39fd522ae632 100644 (file)
@@ -117,8 +117,10 @@ int DecreaseQReference(OneQueItem *MyQItem)
 {
        int IDestructQueItem;
 
+       citthread_mutex_lock(&ActiveQItemsLock);
        MyQItem->ActiveDeliveries--;
        IDestructQueItem = MyQItem->ActiveDeliveries == 0;
+       citthread_mutex_unlock(&ActiveQItemsLock);
        return IDestructQueItem;
 }