diff options
author | Kisuka <Kisuka@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-03-09 12:50:24 +0000 |
---|---|---|
committer | Kisuka <Kisuka@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-03-09 12:50:24 +0000 |
commit | 5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0 (patch) | |
tree | 1f546bf12a99017b41ae2fd90e0ac452f97b0282 /src/common/socket.c | |
parent | b4208257ea0906e375024f811d8e51208d539d35 (diff) | |
download | hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.gz hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.bz2 hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.xz hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.zip |
* Merged changes from trunk [14688:14739/trunk].
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14740 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/socket.c')
-rw-r--r-- | src/common/socket.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/common/socket.c b/src/common/socket.c index ff667cf2e..0a576e517 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -543,18 +543,16 @@ static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseF return 0; } -static int delete_session(int fd) +static void delete_session(int fd) { - if (fd <= 0 || fd >= FD_SETSIZE) - return -1; - if (session[fd]) { + if( session_isValid(fd) ) + { aFree(session[fd]->rdata); aFree(session[fd]->wdata); aFree(session[fd]->session_data); aFree(session[fd]); session[fd] = NULL; } - return 0; } int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size) @@ -584,7 +582,7 @@ int realloc_writefifo(int fd, size_t addition) if( session[fd]->wdata_size + addition > session[fd]->max_wdata ) { // grow rule; grow in multiples of WFIFO_SIZE newsize = WFIFO_SIZE; - while( session[fd]->wdata_size + addition > newsize ) newsize += newsize; + while( session[fd]->wdata_size + addition > newsize ) newsize += WFIFO_SIZE; } else if( session[fd]->max_wdata >= (size_t)2*(session[fd]->flag.server?FIFOSIZE_SERVERLINK:WFIFO_SIZE) @@ -667,9 +665,9 @@ int WFIFOSET(int fd, size_t len) // always keep a WFIFO_SIZE reserve in the buffer // For inter-server connections, let the reserve be 1/4th of the link size. - newreserve = s->wdata_size + ( s->flag.server ? FIFOSIZE_SERVERLINK / 4 : WFIFO_SIZE); + newreserve = s->flag.server ? FIFOSIZE_SERVERLINK / 4 : WFIFO_SIZE; - // readjust the buffer to the newly chosen size + // readjust the buffer to include the chosen reserve realloc_writefifo(fd, newreserve); #ifdef SEND_SHORTLIST @@ -1333,10 +1331,12 @@ void send_shortlist_add_fd(int fd) int i; int bit; - if( fd < 0 || fd >= FD_SETSIZE ) + if( !session_isValid(fd) ) return;// out of range + i = fd/32; bit = fd%32; + if( (send_shortlist_set[i]>>bit)&1 ) return;// already in the list |