#include "commands.h"
#include "ConfigParser.h"
#include "ssl.h"
+#include "QServer.h"
time_t start_time;
static int running, hard_restart;
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();
do {
socket_loop(SOCKET_SELECT_TIME);
} while(time(0) < socket_wait);
- timeq_tick();
- loop_bots();
clearTempUsers();
destroyEvents();
- queue_loop();
}
running_threads--;
return NULL;
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();
register_commands();
init_bots();
init_DBHelper();
+ qserver_init();
load_languages();
int update_minutes = get_int_field("statistics.frequency");
running_threads++;
pthread_create(&tid[tid_id], NULL, thread_main, NULL);
}
+ int usleep_delay = 1000000 / TICKS_PER_SECOND;
+ while(running) {
+ timeq_tick();
+ loop_bots();
+ qserver_loop();
+ queue_loop();
+ usleep(usleep_delay);
+ }
for(tid_id = 0; tid_id < worker_threads; tid_id++) {
pthread_join(tid[tid_id], NULL);
}
loop_bots();
clearTempUsers();
destroyEvents();
+ qserver_loop();
queue_loop();
}
#endif