projects
/
NeonServV5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
trigger join event on Registered rejoin
[NeonServV5.git]
/
src
/
main.c
diff --git
a/src/main.c
b/src/main.c
index 1292a82c7c627c68e6241e80e3dab80fcaf18774..5ab1efd0bd5f93ccce05657783bcdda7f8722484 100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-1,4
+1,4
@@
-/* main.c - NeonServ v5.
4
+/* main.c - NeonServ v5.
6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
@@
-35,11
+35,12
@@
#include "IRCQueue.h"
#include "DBHelper.h"
#include "ConfigParser.h"
#include "IRCQueue.h"
#include "DBHelper.h"
#include "ConfigParser.h"
-#include "ssl.h"
#include "QServer.h"
#include "version.h"
#include "modules.h"
#include "module_commands.h"
#include "QServer.h"
#include "version.h"
#include "modules.h"
#include "module_commands.h"
+#include "ModuleFunctions.h"
+#include "IOHandler.h"
time_t start_time;
static int running, hard_restart;
time_t start_time;
static int running, hard_restart;
@@
-107,30
+108,23
@@
static int load_mysql_config() {
return 1;
}
return 1;
}
-#ifdef HAVE_THREADS
-pthread_t *current_threads = NULL;
+static TIMEQ_CALLBACK(clear_cache) {
+ timeq_add(CLEAR_CACHE_INTERVAL, 0, clear_cache, NULL);
+ clearTempUsers();
+ destroyEvents();
+ mysql_free();
+}
-void * thread_main(void *arg) {
- time_t socket_wait;
+void *thread_main(void *arg) {
while(running) {
while(running) {
- socket_wait = time(0) + SOCKET_SELECT_TIME;
- do {
- if(!socket_loop(SOCKET_SELECT_TIME)) {
- if(!running) break;
- putlog(LOGLEVEL_ERROR, "No more active Bots... shutting down.\n");
- cleanup();
- exit(0);
- }
- } while(time(0) < socket_wait);
- if(!running) break;
- clearTempUsers();
- destroyEvents();
- mysql_free();
+ iohandler_poll();
}
}
- running_threads--;
return NULL;
}
return NULL;
}
+#ifdef HAVE_THREADS
+pthread_t *current_threads = NULL;
+
int getCurrentThreadID() {
if(!current_threads) return 0;
int i;
int getCurrentThreadID() {
if(!current_threads) return 0;
int i;
@@
-208,6
+202,8
@@
int main(int argc, char *argv[]) {
fprintf(stderr, "Unable to load " CONF_FILE "\n");
exit(0);
}
fprintf(stderr, "Unable to load " CONF_FILE "\n");
exit(0);
}
+ init_bind();
+ event_reload(1);
#if HAVE_THREADS
THREAD_MUTEX_INIT(log_sync);
#endif
#if HAVE_THREADS
THREAD_MUTEX_INIT(log_sync);
#endif
@@
-261,18
+257,6
@@
main:
start_time = time(0);
start_time = time(0);
- #ifdef WIN32
- int res;
- WSADATA wsadata;
- // Start Windows Sockets.
- res = WSAStartup(MAKEWORD(2, 0), &wsadata);
- if (res)
- {
- perror("Unable to start Windows Sockets");
- return 0;
- }
- #endif
-
statistics_enabled = get_int_field("statistics.enable");
#ifdef HAVE_THREADS
statistics_enabled = get_int_field("statistics.enable");
#ifdef HAVE_THREADS
@@
-281,11
+265,7
@@
main:
THREAD_MUTEX_INIT(whohandler_mass_sync);
#endif
THREAD_MUTEX_INIT(whohandler_mass_sync);
#endif
- queue_init();
- init_sockets();
- init_timeq();
init_lang();
init_lang();
- ssl_init();
init_parser();
init_UserNode();
init_ChanNode();
init_parser();
init_UserNode();
init_ChanNode();
@@
-295,6
+275,7
@@
main:
register_module_commands();
init_handleinfohandler();
init_tools();
register_module_commands();
init_handleinfohandler();
init_tools();
+ init_modulefunctions();
loadModules();
init_bots();
init_DBHelper();
loadModules();
init_bots();
init_DBHelper();
@@
-307,6
+288,8
@@
main:
timeq_add(90, 0, main_checkauths, NULL);
timeq_add(90, 0, main_checkauths, NULL);
+ timeq_add(CLEAR_CACHE_INTERVAL, 0, clear_cache, NULL);
+
int worker_threads = get_int_field("General.worker_threads");
if(!worker_threads) worker_threads = 1;
running = 1;
int worker_threads = get_int_field("General.worker_threads");
if(!worker_threads) worker_threads = 1;
running = 1;
@@
-317,38
+300,13
@@
main:
running_threads++;
pthread_create(¤t_threads[tid_id], NULL, thread_main, NULL);
}
running_threads++;
pthread_create(¤t_threads[tid_id], NULL, thread_main, NULL);
}
- int usleep_delay = 1000000 / TICKS_PER_SECOND;
- while(running) {
- timeq_tick();
- loop_modules();
- qserver_loop();
- queue_loop();
- mysql_free();
- usleep(usleep_delay);
- }
+ #endif
+ thread_main(NULL);
+ #ifdef HAVE_THREADS
for(tid_id = 0; tid_id < worker_threads; tid_id++) {
pthread_join(current_threads[tid_id], NULL);
}
running_threads = 0;
for(tid_id = 0; tid_id < worker_threads; tid_id++) {
pthread_join(current_threads[tid_id], NULL);
}
running_threads = 0;
- #else
- time_t socket_wait;
- while(running) {
- socket_wait = time(0) + SOCKET_SELECT_TIME;
- do {
- if(!socket_loop(SOCKET_SELECT_TIME)) {
- putlog(LOGLEVEL_ERROR, "No more active Bots... shutting down.\n");
- cleanup();
- exit(0);
- }
- } while(time(0) < socket_wait);
- timeq_tick();
- loop_modules();
- clearTempUsers();
- destroyEvents();
- qserver_loop();
- queue_loop();
- mysql_free();
- }
#endif
cleanup();
if(hard_restart) {
#endif
cleanup();
if(hard_restart) {
@@
-410,6
+368,7
@@
void stop_bot() {
void reload_config() {
loadConfig(CONF_FILE);
void reload_config() {
loadConfig(CONF_FILE);
+ event_reload(0);
}
static int getCurrentSecondsOfDay() {
}
static int getCurrentSecondsOfDay() {
@@
-437,10
+396,16
@@
static AUTHLOOKUP_CALLBACK(main_checkauths_callback) {
deleteUser(atoi(row[0]));
char *alertchan = get_string_field("General.CheckAuths.alertchan");
if(alertchan) {
deleteUser(atoi(row[0]));
char *alertchan = get_string_field("General.CheckAuths.alertchan");
if(alertchan) {
+ char reason[MAXLEN];
+ if(!exists) {
+ strcpy(reason, "USER_NOT_EXISTS");
+ } else {
+ sprintf(reason, "USER_REGISTERED_MISSMATCH: %lu, expected %d (diff: %d)", (unsigned long) registered, atoi(row[1]), diff);
+ }
struct ChanNode *alertchan_chan = getChanByName(alertchan);
struct ClientSocket *alertclient;
if(alertchan_chan && (alertclient = getChannelBot(alertchan_chan, 0)) != NULL) {
struct ChanNode *alertchan_chan = getChanByName(alertchan);
struct ClientSocket *alertclient;
if(alertchan_chan && (alertclient = getChannelBot(alertchan_chan, 0)) != NULL) {
- putsock(alertclient, "PRIVMSG %s :Deleted User %s
", alertchan_chan->name, auth
);
+ putsock(alertclient, "PRIVMSG %s :Deleted User %s
(%s)", alertchan_chan->name, auth, reason
);
}
}
} else if(exists && !strcmp(row[1], "0")) {
}
}
} else if(exists && !strcmp(row[1], "0")) {