[Freeciv-Dev] (PR#13765) bugs with LAN server detection
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13765 >
Try the following experiment:
- Start about 6 servers on different ports on localhost.
- Use the client lanserver tab to find them.
You'll see at least two bugs:
1. The client can detect at most 1 server per second.
2. Some servers aren't detected at all.
These are symptoms of the same bug: get_lanserver_list can only detect
one server per call, and it may be a repeat.
This patch fixes it in 2.0. The easy/safe way is just to use a goto to
keep looping until there's no more data.
For 2.1 we can probably do better with a loop. In fact I doubt the
select() is even needed since recvfrom returns -1 if there's no data
pending (we're polling anyway, so...).
See also PR#13714 (in which the bug was first discovered).
-jason
Index: client/clinet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v
retrieving revision 1.102.2.9
diff -p -u -r1.102.2.9 clinet.c
--- client/clinet.c 15 Apr 2005 20:24:44 -0000 1.102.2.9
+++ client/clinet.c 24 Aug 2005 20:55:33 -0000
@@ -834,6 +834,8 @@ struct server_list *get_lan_server_list(
fd_set readfs, exceptfs;
struct timeval tv;
+ again:
+
FD_ZERO(&readfs);
FD_ZERO(&exceptfs);
FD_SET(socklan, &exceptfs);
@@ -864,7 +866,7 @@ struct server_list *get_lan_server_list(
dio_get_uint8(&din, &type);
if (type != SERVER_LAN_VERSION) {
- return lan_servers;
+ goto again;
}
dio_get_string(&din, servername, sizeof(servername));
dio_get_string(&din, port, sizeof(port));
@@ -883,7 +885,7 @@ struct server_list *get_lan_server_list(
server_list_iterate(*lan_servers, aserver) {
if (!mystrcasecmp(aserver->host, servername)
&& !mystrcasecmp(aserver->port, port)) {
- return lan_servers;
+ goto again;
}
} server_list_iterate_end;
@@ -900,9 +902,9 @@ struct server_list *get_lan_server_list(
pserver->players = NULL;
server_list_insert(lan_servers, pserver);
- } else {
- return lan_servers;
- }
+
+ goto again;
+ }
return lan_servers;
}
- [Freeciv-Dev] (PR#13765) bugs with LAN server detection,
Jason Short <=
|
|