From 4590182c2c88f0b9e5eb70b45e882d9381fe33b6 Mon Sep 17 00:00:00 2001 From: skotlex Date: Wed, 13 Dec 2006 13:45:52 +0000 Subject: - Modified flush_fifo so you can decide whether to block the current thread or not until the data is sent. The server-tick reply no longer blocks the current thread. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9486 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/common/socket.c') diff --git a/src/common/socket.c b/src/common/socket.c index fafa229df..19a2ecdea 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -283,14 +283,19 @@ static int send_from_fifo(int fd) return 0; } -void flush_fifo(int fd) +void flush_fifo(int fd, int lock) { - if(session[fd] != NULL && session[fd]->func_send == send_from_fifo) - { + if(session[fd] == NULL || session[fd]->func_send != send_from_fifo) + return; + if (lock) + { //Lock the thread until data is sent. set_nonblocking(fd, 1); send_from_fifo(fd); set_nonblocking(fd, 0); + return; } + //Send without locking the thread. + send_from_fifo(fd); } void flush_fifos(void) -- cgit v1.2.3-70-g09d2