diff options
Diffstat (limited to 'src/char_sql/inter.c')
-rw-r--r-- | src/char_sql/inter.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 5a220ef7f..38fd1f289 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -303,6 +303,17 @@ int inter_log(char *fmt,...) return 0;
}
+/*======================================================
+ * Does a mysql_ping to all connection handles. [Skotlex]
+ *------------------------------------------------------
+ */
+int inter_sql_ping(int tid, unsigned int tick, int id, int data)
+{
+ mysql_ping(&mysql_handle);
+ if(char_gm_read)
+ mysql_ping(&lmysql_handle);
+ return 0;
+}
// initialize
int inter_init(const char *file)
@@ -325,15 +336,17 @@ int inter_init(const char *file) ShowStatus("Connect Success! (Character Server)\n");
}
- mysql_init(&lmysql_handle);
- ShowInfo("Connect Character DB server.... (login server)\n");
- if(!mysql_real_connect(&lmysql_handle, login_server_ip, login_server_id, login_server_pw,
- login_server_db ,login_server_port, (char *)NULL, 0)) {
- //pointer check
- ShowFatalError("%s\n",mysql_error(&lmysql_handle));
- exit(1);
- }else {
- ShowStatus ("Connect Success! (Login Server)\n");
+ if(char_gm_read) {
+ mysql_init(&lmysql_handle);
+ ShowInfo("Connect Character DB server.... (login server)\n");
+ if(!mysql_real_connect(&lmysql_handle, login_server_ip, login_server_id, login_server_pw,
+ login_server_db ,login_server_port, (char *)NULL, 0)) {
+ //pointer check
+ ShowFatalError("%s\n",mysql_error(&lmysql_handle));
+ exit(1);
+ }else {
+ ShowStatus ("Connect Success! (Login Server)\n");
+ }
}
if(strlen(default_codepage) > 0 ) {
sprintf( tmp_sql, "SET NAMES %s", default_codepage );
@@ -341,10 +354,11 @@ int inter_init(const char *file) ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
- if (mysql_query(&lmysql_handle, tmp_sql)) {
- ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
+ if(char_gm_read)
+ if (mysql_query(&lmysql_handle, tmp_sql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
+ }
}
wis_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int));
inter_guild_sql_init();
@@ -357,6 +371,11 @@ int inter_init(const char *file) //printf ("interserver timer initializing : %d sec...\n",autosave_interval);
//i=add_timer_interval(gettick()+autosave_interval,inter_save_timer,0,0,autosave_interval);
+ if (connection_ping_interval) {
+ add_timer_func_list(inter_sql_ping, "inter_sql_ping");
+ add_timer_interval(gettick()+connection_ping_interval*60*1000,
+ inter_sql_ping, 0, 0, connection_ping_interval*60*1000);
+ }
return 0;
}
|