added QServer for external cache access
[NeonServV5.git] / src / main.c
index ffa830d2a90563b04f67c442a339feb45327596b..e8d366aa0d7141696c51b302cc900f2b961fa3c2 100644 (file)
@@ -36,6 +36,7 @@
 #include "commands.h"
 #include "ConfigParser.h"
 #include "ssl.h"
+#include "QServer.h"
 
 time_t start_time;
 static int running, hard_restart;
@@ -44,10 +45,13 @@ int statistics_enabled;
 TIMEQ_CALLBACK(main_statistics);
 #ifdef HAVE_THREADS
 int running_threads;
+pthread_mutex_t cache_sync;
+pthread_mutex_t whohandler_sync, whohandler_mass_sync;
 #endif
 
 void cleanup() {
     free_sockets();
+    qserver_free();
     free_parser();
     free_UserNode();
     free_ChanNode();
@@ -132,6 +136,12 @@ main:
     
     statistics_enabled = get_int_field("statistics.enable");
     
+    #ifdef HAVE_THREADS
+    THREAD_MUTEX_INIT(cache_sync);
+    THREAD_MUTEX_INIT(whohandler_sync);
+    THREAD_MUTEX_INIT(whohandler_mass_sync);
+    #endif
+    
     queue_init();
     init_sockets();
     init_timeq();
@@ -148,6 +158,7 @@ main:
     register_commands();
     init_bots();
     init_DBHelper();
+    qserver_init();
     
     load_languages();
     int update_minutes = get_int_field("statistics.frequency");
@@ -169,6 +180,7 @@ main:
     while(running) {
         timeq_tick();
         loop_bots();
+        qserver_loop();
         queue_loop();
         usleep(usleep_delay);
     }
@@ -187,6 +199,7 @@ main:
         loop_bots();
         clearTempUsers();
         destroyEvents();
+        qserver_loop();
         queue_loop();
     }
     #endif