From 23867efcc4336f811cf6c424a62110d514ee8293 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Wed, 6 Dec 2006 10:57:31 +0000 Subject: - Messages with server_tick field are sent as soon as possible now. This might fix client synchronization issues. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9415 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/plugins.c | 8 +++++++- src/common/socket.c | 8 +++++--- src/common/socket.h | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/common') diff --git a/src/common/plugins.c b/src/common/plugins.c index 5951885a1..9da12c35f 100644 --- a/src/common/plugins.c +++ b/src/common/plugins.c @@ -291,6 +291,12 @@ int plugins_config_read(const char *cfgName) return 0; } +/// backward compatibillity function +int plugin_WFIFOSET(int fd,int len) +{ + return _WFIFOSET(fd,len,0); +} + void plugins_init (void) { char *PLUGIN_CONF_FILENAME = "conf/plugin_athena.conf"; @@ -302,7 +308,7 @@ void plugins_init (void) // networking export_symbol (func_parse_table, 18); export_symbol (RFIFOSKIP, 17); - export_symbol (WFIFOSET, 16); + export_symbol (plugin_WFIFOSET, 16); export_symbol (delete_session, 15); export_symbol (session, 14); export_symbol (&fd_max, 13); diff --git a/src/common/socket.c b/src/common/socket.c index bedad4ed0..dcaf2cdf2 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -687,7 +687,7 @@ int realloc_writefifo(int fd, size_t addition) return 0; } -int WFIFOSET(int fd,int len) +int _WFIFOSET(int fd, int len, char flush) { size_t newreserve; struct socket_data *s = session[fd]; @@ -712,7 +712,9 @@ int WFIFOSET(int fd,int len) // For inter-server connections, let the reserve be 1/4th of the link size. newreserve = s->wdata_size + (s->max_wdata>=FIFOSIZE_SERVERLINK?FIFOSIZE_SERVERLINK/4:wfifo_size); - if(s->wdata_size >= frame_size) + if( flush ) + flush_fifo(fd); + else if(s->wdata_size >= frame_size) send_from_fifo(fd); // realloc after sending @@ -807,7 +809,7 @@ int do_sendrecv(int next) if(session[i]->wdata_size && session[i]->func_send) session[i]->func_send(i); - if(session[i]->eof) //The session check is for when the connection ended in func_parse + if(session[i] && session[i]->eof) //The session check is for when the connection ended in func_parse { //Finally, even if there is no data to parse, connections signalled eof should be closed, so we call parse_func [Skotlex] if (session[i]->func_parse) session[i]->func_parse(i); //This should close the session inmediately. diff --git a/src/common/socket.h b/src/common/socket.h index 9552575f3..2c0412a9e 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -67,6 +67,8 @@ extern time_t stall_time; #define WFIFOL(fd,pos) (*(unsigned long*)WFIFOP(fd,pos)) // use function instead of macro. //#define WFIFOSET(fd,len) (session[fd]->wdata_size = (session[fd]->wdata_size + (len) + 2048 < session[fd]->max_wdata) ? session[fd]->wdata_size + len : session[fd]->wdata_size) +#define WFIFOSET(fd,len) _WFIFOSET(fd,len,0) +#define WFIFOSET2(fd,len,flush) _WFIFOSET(fd,len,flush) #define WBUFP(p,pos) (((unsigned char*)(p)) + (pos)) #define WBUFB(p,pos) (*(unsigned char*)((p) + (pos))) #define WBUFW(p,pos) (*(unsigned short*)((p) + (pos))) @@ -149,7 +151,7 @@ int make_connection(long,int); int delete_session(int); int realloc_fifo(int fd,unsigned int rfifo_size,unsigned int wfifo_size); int realloc_writefifo(int fd, size_t addition); -int WFIFOSET(int fd,int len); +int _WFIFOSET(int fd,int len,char flush); int RFIFOSKIP(int fd,int len); int do_sendrecv(int next); -- cgit v1.2.3-70-g09d2