From a0fb6bc388fb1d4f0fcfd7d3d8af71a9c8cf86ca Mon Sep 17 00:00:00 2001 From: shennetsind Date: Wed, 31 Oct 2012 20:17:38 +0000 Subject: Fixed bugreport:6779 dropped between-server ping timers, replaced by a much more reliable and performance-efficient on-demand flagging. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16854 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 14 +++++++++++--- src/common/socket.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/socket.c b/src/common/socket.c index 3d7bb66b4..d24a9c1d8 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -797,8 +797,13 @@ int do_sockets(int next) continue; if (session[i]->rdata_tick && DIFF_TICK(last_tick, session[i]->rdata_tick) > stall_time) { - ShowInfo("Session #%d timed out\n", i); - set_eof(i); + if( session[i]->flag.server ) {/* server is special */ + if( session[i]->flag.ping != 2 )/* only update if necessary otherwise it'd resend the ping unnecessarily */ + session[i]->flag.ping = 1; + } else { + ShowInfo("Session #%d timed out\n", i); + set_eof(i); + } } session[i]->func_parse(i); @@ -1073,8 +1078,11 @@ int socket_config_read(const char* cfgName) if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) continue; - if (!strcmpi(w1, "stall_time")) + if (!strcmpi(w1, "stall_time")) { stall_time = atoi(w2); + if( stall_time < 3 ) + stall_time = 3;/* a minimum is required to refrain it from killing itself */ + } #ifndef MINICORE else if (!strcmpi(w1, "enable_ip_rules")) { ip_rules = config_switch(w2); diff --git a/src/common/socket.h b/src/common/socket.h index 3265f6487..7c0e02f5d 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -76,6 +76,7 @@ struct socket_data struct { unsigned char eof : 1; unsigned char server : 1; + unsigned char ping : 2; } flag; uint32 client_addr; // remote client address -- cgit v1.2.3-60-g2f50