added experimental multi thread support
[NeonServV5.git] / src / HandleInfoHandler.c
index 8a135cdb16c8453b2d87d0f09b2c1c8fb409b587..99d19658b73c33d6b24abb729988eecbc44cc746 100644 (file)
@@ -1,5 +1,5 @@
-/* HandleInfoHandler.c - NeonServ v5.2
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* HandleInfoHandler.c - NeonServ v5.3
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
 #include "HandleInfoHandler.h"
 #include "ClientSocket.h"
 #include "UserNode.h"
+#include "ChanNode.h"
 #include "IRCEvents.h"
 #include "tools.h"
 
@@ -40,17 +41,20 @@ static struct HandleInfoQueueEntry* addHandleInfoQueueEntry(struct ClientSocket
         perror("malloc() failed");
         return NULL;
     }
+    SYNCHRONIZE(cache_sync);
     entry->next = NULL;
     if(client->handleinfo_last)
         client->handleinfo_last->next = entry;
     else
         client->handleinfo_first = entry;
     client->handleinfo_last = entry;
+    DESYNCHRONIZE(cache_sync);
     return entry;
 }
 
 static struct HandleInfoQueueEntry* getNextHandleInfoQueueEntry(struct ClientSocket *client, int freeEntry) {
     if(!client->handleinfo_first) return NULL;
+    SYNCHRONIZE(cache_sync);
     struct HandleInfoQueueEntry *entry = client->handleinfo_first;
     if(freeEntry) {
         client->handleinfo_first = entry->next;
@@ -58,17 +62,21 @@ static struct HandleInfoQueueEntry* getNextHandleInfoQueueEntry(struct ClientSoc
             client->handleinfo_last = NULL;
         }
     }
+    DESYNCHRONIZE(cache_sync);
     return entry;
 }
 
 void clear_handleinfoqueue(struct ClientSocket *client) {
     if(!client->handleinfo_first) return;
+    SYNCHRONIZE(cache_sync);
     struct HandleInfoQueueEntry *entry, *next;
     for(entry = client->handleinfo_first; entry; entry = next) {
         next = entry->next;
         free(entry);
     }
     client->handleinfo_last = NULL;
+    client->handleinfo_first = NULL;
+    DESYNCHRONIZE(cache_sync);
 }
 
 void lookup_authname(char *auth, authlookup_callback_t callback, void *data) {