added experimental multi thread support
[NeonServV5.git] / src / WHOHandler.c
index 61f2ed2afec8f894ad4353eba8eea3e976cb4ad7..a8a55d91c693956cebd57329babecb6ec73fa829 100644 (file)
@@ -46,6 +46,7 @@ static struct WHOQueueEntry* addWHOQueueEntry(struct ClientSocket *client) {
         perror("malloc() failed");
         return NULL;
     }
+    SYNCHRONIZE(cache_sync);
     entry->next = NULL;
     if(client->whoqueue_last) {
         client->whoqueue_last->next = entry;
@@ -53,11 +54,13 @@ static struct WHOQueueEntry* addWHOQueueEntry(struct ClientSocket *client) {
         client->whoqueue_first = entry;
     }
     client->whoqueue_last = entry;
+    DESYNCHRONIZE(cache_sync);
     return entry;
 }
 
 static struct WHOQueueEntry* getNextWHOQueueEntry(struct ClientSocket *client, int freeEntry) {
     if(!client->whoqueue_first) return NULL;
+    SYNCHRONIZE(cache_sync);
     struct WHOQueueEntry *entry = client->whoqueue_first;
     if(freeEntry) {
         client->whoqueue_first = entry->next;
@@ -65,11 +68,13 @@ static struct WHOQueueEntry* getNextWHOQueueEntry(struct ClientSocket *client, i
             client->whoqueue_last = NULL;
         }
     }
+    DESYNCHRONIZE(cache_sync);
     return entry;
 }
 
 void clear_whoqueue(struct ClientSocket *client) {
     if(!client->whoqueue_first) return;
+    SYNCHRONIZE(cache_sync);
     struct WHOQueueEntry *entry, *next;
     for(entry = client->whoqueue_first; entry; entry = next) {
         next = entry->next;
@@ -77,6 +82,7 @@ void clear_whoqueue(struct ClientSocket *client) {
     }
     client->whoqueue_last = NULL;
     client->whoqueue_first = NULL;
+    DESYNCHRONIZE(cache_sync);
 }
 
 void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *data) {