diff options
author | amber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-01-06 15:02:42 +0000 |
---|---|---|
committer | amber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-01-06 15:02:42 +0000 |
commit | 28cb9b9d074dbefa1e5de9805ff172f7dbd39da4 (patch) | |
tree | 97e50481ade2a54e0232cc68f8645a7a3184264e /src/common/socket.c | |
parent | 57d0506ec4a06a8330a0f344e77ff9dba1bede5c (diff) | |
download | hercules-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
Diffstat (limited to 'src/common/socket.c')
-rw-r--r-- | src/common/socket.c | 14 |
1 files changed, 11 insertions, 3 deletions
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){ |