Sfoglia il codice sorgente

- 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://svn.code.sf.net/p/rathena/svn/trunk@9486 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 18 anni fa
parent
commit
0c362fa90f
4 ha cambiato i file con 13 aggiunte e 5 eliminazioni
  1. 3 0
      Changelog-Trunk.txt
  2. 8 3
      src/common/socket.c
  3. 1 1
      src/common/socket.h
  4. 1 1
      src/map/clif.c

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/12/13
+	* 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.
 	* Fixed mobs being unable to attack anything... 
 2006/12/12
 	* Reverted the knockback update since it isn't working right with all

+ 8 - 3
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)

+ 1 - 1
src/common/socket.h

@@ -158,7 +158,7 @@ void do_close(int fd);
 void socket_init(void);
 void socket_final(void);
 
-extern void flush_fifo(int fd);
+extern void flush_fifo(int fd, int lock);
 extern void flush_fifos(void);
 extern void set_nonblocking(int fd, int yes);
 

+ 1 - 1
src/map/clif.c

@@ -8502,7 +8502,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) {
 	WFIFOW(fd,0)=0x7f;
 	WFIFOL(fd,2)=gettick();
 	WFIFOSET(fd,packet_len_table[0x7f]);
-	flush_fifo(fd); // send immediatly so the client gets accurate "pings"
+	flush_fifo(fd,0); // send immediatly so the client gets accurate "pings"
 	return;
 }