summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-06 15:02:42 +0000
committeramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-06 15:02:42 +0000
commit28cb9b9d074dbefa1e5de9805ff172f7dbd39da4 (patch)
tree97e50481ade2a54e0232cc68f8645a7a3184264e
parent57d0506ec4a06a8330a0f344e77ff9dba1bede5c (diff)
downloadhercules-28cb9b9d074dbefa1e5de9805ff172f7dbd39da4.tar.gz
hercules-28cb9b9d074dbefa1e5de9805ff172f7dbd39da4.tar.bz2
hercules-28cb9b9d074dbefa1e5de9805ff172f7dbd39da4.tar.xz
hercules-28cb9b9d074dbefa1e5de9805ff172f7dbd39da4.zip
update
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@924 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog.txt15
-rw-r--r--conf-tmpl/login_athena.conf3
-rw-r--r--src/common/core.c2
-rw-r--r--src/common/socket.c14
-rw-r--r--src/common/socket.h6
-rw-r--r--src/map/clif.c5
-rw-r--r--src/map/map.c8
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/party.c2
-rw-r--r--src/map/pc.c30
-rw-r--r--src/map/pc.h3
11 files changed, 43 insertions, 46 deletions
diff --git a/Changelog.txt b/Changelog.txt
index de35e52a4..e947ea7b2 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,4 +1,19 @@
Date Added
+01/06
+ * Fixed typo in src/map/map.c causing compile
+ errors (SVN 924) [MouseJstr]
+ * Removed the alive_timer mechanism entirly replaced with
+ a stall detection mechanism that will disconnect a player
+ who has not sent any data for a configurable
+ (conf/login_athena.conf:stall_time) amount of time. The default
+ is currently 60 seconds.
+
+ The root cause of the disconnect error is that some NAT based
+ routers are not dropping the TCP connection when the aliased
+ machine goes offline abnormally. This means that we are seeing
+ a stalled but perfectly valid TCP connection.
+
+ (SVN 924) [MouseJstr]
01/05
* Fixed some typos in map_versionscreen() [MC Cameri]
* Removed loop freeing in map-server's do_final(), it was causing seg faults [MC Cameri]
diff --git a/conf-tmpl/login_athena.conf b/conf-tmpl/login_athena.conf
index d58e8e09c..4758f7dc0 100644
--- a/conf-tmpl/login_athena.conf
+++ b/conf-tmpl/login_athena.conf
@@ -151,4 +151,7 @@ flush_on: 0
// How often to flush the buffer in Mugendai's GUI
flush_time: 60
+// How long can a socket stall before closing the connection
+stall_time: 60
+
import: conf/import/login_conf.txt
diff --git a/src/common/core.c b/src/common/core.c
index 2e0029ea1..493aab850 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -169,6 +169,8 @@ int main(int argc,char **argv)
display_title();
+ tick_ = time(0);
+
do_init(argc,argv);
while(runflag){
next=do_timer(gettick_nocache());
diff --git a/src/common/socket.c b/src/common/socket.c
index 5d7d0775e..764d4d821 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -37,6 +37,8 @@
fd_set readfds;
int fd_max;
+time_t tick_;
+time_t stall_time_ = 60;
int rfifo_size = 65536;
int wfifo_size = 65536;
@@ -106,6 +108,7 @@ static int recv_to_fifo(int fd)
//{ int i; printf("recv %d : ",fd); for(i=0;i<len;i++){ printf("%02x ",RFIFOB(fd,session[fd]->rdata_size+i)); } printf("\n");}
if(len>0){
session[fd]->rdata_size+=len;
+ session[fd]->rdata_tick = tick_;
} else if(len<=0){
// value of connection is not necessary the same
// printf("set eof : connection #%d\n", fd);
@@ -209,6 +212,7 @@ static int connect_client(int listen_fd)
session[fd]->func_send = send_from_fifo;
session[fd]->func_parse = default_func_parse;
session[fd]->client_addr = client_address;
+ session[fd]->rdata_tick = tick_;
//printf("new_session : %d %d\n",fd,session[fd]->eof);
return fd;
@@ -347,6 +351,7 @@ int make_connection(long ip,int port)
session[fd]->func_recv = recv_to_fifo;
session[fd]->func_send = send_from_fifo;
session[fd]->func_parse = default_func_parse;
+ session[fd]->rdata_tick = tick_;
return fd;
}
@@ -407,7 +412,10 @@ int do_sendrecv(int next)
struct timeval timeout;
int ret,i;
- rfd=readfds;
+ tick_ = time(0);
+
+ memcpy(&rfd, &readfds, sizeof(rfd));
+
FD_ZERO(&wfd);
for(i=0;i<fd_max;i++){
if(!session[i] && FD_ISSET(i,&readfds)){
@@ -431,13 +439,11 @@ int do_sendrecv(int next)
if(FD_ISSET(i,&wfd)){
//printf("write:%d\n",i);
if(session[i]->func_send)
- //send_from_fifo(i);
session[i]->func_send(i);
}
if(FD_ISSET(i,&rfd)){
//printf("read:%d\n",i);
if(session[i]->func_recv)
- //recv_to_fifo(i);
session[i]->func_recv(i);
}
}
@@ -450,6 +456,8 @@ int do_parsepacket(void)
for(i=0;i<fd_max;i++){
if(!session[i])
continue;
+ if ((session[i]->rdata_tick != 0) && ((tick_ - session[i]->rdata_tick) > stall_time_))
+ session[i]->eof = 1;
if(session[i]->rdata_size==0 && session[i]->eof==0)
continue;
if(session[i]->func_parse){
diff --git a/src/common/socket.h b/src/common/socket.h
index e5e065f33..172712d26 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -12,8 +12,13 @@
#include <sys/socket.h>
#include <netinet/in.h>
#endif
+#include <time.h>
+
#include "malloc.h"
+extern time_t tick_;
+extern time_t stall_time_;
+
// define declaration
#define RFIFOP(fd,pos) (session[fd]->rdata+session[fd]->rdata_pos+(pos))
@@ -55,6 +60,7 @@ struct socket_data{
unsigned char *rdata,*wdata;
int max_rdata,max_wdata;
int rdata_size,wdata_size;
+ time_t rdata_tick;
int rdata_pos;
struct sockaddr_in client_addr;
int (*func_recv)(int);
diff --git a/src/map/clif.c b/src/map/clif.c
index af89df654..0412192e1 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7545,11 +7545,6 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) {
break;
}
- //double connection bug fix by Valaris
- if(sd->alive_timer > 0)
- delete_timer(sd->alive_timer,pc_alive_timer);
- sd->alive_timer=add_timer(gettick()+60*1000,pc_alive_timer,sd->bl.id,0);
-
sd->server_tick = gettick();
clif_servertick(sd);
}
diff --git a/src/map/map.c b/src/map/map.c
index 6c028628d..039bdc5f2 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1051,12 +1051,6 @@ int map_quit(struct map_session_data *sd) {
storage_storage_dirty(sd);
storage_storage_save(sd);
- //double connect bug fix by Valaris
- if(sd->alive_timer > 0) {
- delete_timer(sd->alive_timer,pc_alive_timer);
- sd->alive_timer = -1; // not 0, the server will assume it's still active
- }
-
if( sd->npc_stackbuf && sd->npc_stackbuf != NULL) {
free( sd->npc_stackbuf );
sd->npc_stackbuf = NULL;
@@ -2440,6 +2434,8 @@ int sql_config_read(char *cfgName)
strcpy(login_server_pw, w2);
} else if(strcmpi(w1,"login_server_db")==0){
strcpy(login_server_db, w2);
+ } else if(strcmpi(w1,"stall_time")==0){
+ stall_time_ = atoi(w2);
} else if(strcmpi(w1,"lowest_gm_level")==0){
lowest_gm_level = atoi(w2);
} else if(strcmpi(w1,"read_gm_interval")==0){
diff --git a/src/map/map.h b/src/map/map.h
index 289e8338b..f25ebba30 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -332,7 +332,6 @@ struct map_session_data {
int last_skillid,last_skilllv; // Added by RoVeRT
unsigned char change_level; // [celest]
- int alive_timer; //[Valaris]
#ifndef TXT_ONLY
int mail_counter; // mail counter for mail system [Valaris]
diff --git a/src/map/party.c b/src/map/party.c
index ddaed7fc7..28f05bab9 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -591,7 +591,7 @@ int party_exp_share(struct party *p,int map,int base_exp,int job_exp,int zeny)
return 0;
for(i=0;i<MAX_PARTY;i++)
if((sd=p->member[i].sd)!=NULL && sd->bl.m==map && session[sd->fd] != NULL) {
- if (/* pc_issit(sd) || */ sd->chatID || (sd->idletime < (time(0) - 120)))
+ if (/* pc_issit(sd) || */ sd->chatID || (sd->idletime < (tick_ - 120)))
continue;
#ifdef TWILIGHT
pc_gainexp(sd,base_exp,job_exp);
diff --git a/src/map/pc.c b/src/map/pc.c
index 14ee9b097..3dbfc4e88 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4016,11 +4016,6 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt
// map_addblock(&sd->bl); /// ブロック登?とspawnは
// clif_spawnpc(sd);
- //double connection bug fix by Valaris
- if(sd->alive_timer > 0)
- delete_timer(sd->alive_timer,pc_alive_timer);
- sd->alive_timer=add_timer(gettick()+60*1000,pc_alive_timer,sd->bl.id,0);
-
return 0;
}
@@ -4323,7 +4318,7 @@ int pc_walktoxy(struct map_session_data *sd,int x,int y)
sd->to_x=x;
sd->to_y=y;
- sd->idletime = time(0);
+ sd->idletime = tick_;
if(sd->walktimer != -1 && sd->state.change_walk_target==0){
// 現在?いている最中の目的地?更なのでマス目の中心に?た暫ノ
@@ -4652,7 +4647,7 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data)
if(sd == NULL)
return 0;
- sd->idletime = time(0);
+ sd->idletime = tick_;
if(sd->attacktimer != tid){
if(battle_config.error_log)
@@ -4773,7 +4768,7 @@ int pc_attack(struct map_session_data *sd,int target_id,int type)
if(bl==NULL)
return 1;
- sd->idletime = time(0);
+ sd->idletime = tick_;
if(bl->type==BL_NPC) { // monster npcs [Valaris]
//npc_click(sd,RFIFOL(sd->fd,2));
@@ -7894,24 +7889,6 @@ int map_night_timer(int tid, unsigned int tick, int id, int data) { // by [yor]
return 0;
}
-/*==========================================
- * I'm alive timer (to prevent double connect bug) by Valaris
- *------------------------------------------
- */
-int pc_alive_timer(int tid,unsigned int tick,int id,int data)
-{
- //struct map_session_data *sd=(struct map_session_data*)map_id2bl(id);
- struct map_session_data *sd=map_id2sd(id); // more accurate [celest]
- nullpo_retr(0, sd);
- if(sd->alive_timer != tid)
- return 0;
- sd->alive_timer = -1;
-// map_quit(sd);
- clif_timedout (sd);
-
- return 0;
-}
-
void pc_setstand(struct map_session_data *sd){
nullpo_retv(sd);
@@ -8308,7 +8285,6 @@ int do_init_pc(void) {
// add night/day timer (by [yor])
add_timer_func_list(map_day_timer, "map_day_timer"); // by [yor]
add_timer_func_list(map_night_timer, "map_night_timer"); // by [yor]
- add_timer_func_list(pc_alive_timer, "pc_alive_timer"); //by Valaris
{
int day_duration = battle_config.day_duration;
int night_duration = battle_config.night_duration;
diff --git a/src/map/pc.h b/src/map/pc.h
index a32926886..02dfcb74a 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -200,8 +200,5 @@ extern int night_timer_tid;
int map_day_timer(int,unsigned int,int,int); // by [yor]
int map_night_timer(int,unsigned int,int,int); // by [yor]
-//double connect bug fix
-int pc_alive_timer(int tid,unsigned int tick,int,int);
-
#endif