Date: Thursday October 26, 2000 @ 5:06
Author: xyzzy
Update of /home/netrek/cvsroot/Vanilla/ntserv
In directory swashbuckler.fortress.real-time.com:/var/tmp/cvs-serv30198
Modified Files:
getentry.c getname.c main.c proto.h socket.c
Log Message:
Fix problem where if the client disconnected while the server was waiting for
the version packet, ntserv would not check for the client dying suck up 100%
CPU.
Also add a parameter to socketPause() with the timeout to wait for.
****************************************
Index: Vanilla/ntserv/getentry.c
diff -u Vanilla/ntserv/getentry.c:1.7 Vanilla/ntserv/getentry.c:1.8
--- Vanilla/ntserv/getentry.c:1.7 Tue Aug 15 05:16:28 2000
+++ Vanilla/ntserv/getentry.c Thu Oct 26 05:06:14 2000
@@ -45,7 +45,7 @@
me->p_status=PDEAD;
me->p_explode=600;
}
- socketPause();
+ socketPause(1);
readFromClient();
if (isClientDead()) {
int i;
Index: Vanilla/ntserv/getname.c
diff -u Vanilla/ntserv/getname.c:1.9 Vanilla/ntserv/getname.c:1.10
--- Vanilla/ntserv/getname.c:1.9 Fri Jun 23 04:12:58 2000
+++ Vanilla/ntserv/getname.c Thu Oct 26 05:06:14 2000
@@ -62,7 +62,7 @@
/* Been ghostbusted? */
if (me->p_status==PFREE) exitGame();
if (isClientDead()) exitGame();
- socketPause();
+ socketPause(1);
readFromClient();
}
Index: Vanilla/ntserv/main.c
diff -u Vanilla/ntserv/main.c:1.19 Vanilla/ntserv/main.c:1.20
--- Vanilla/ntserv/main.c:1.19 Tue Aug 15 05:16:28 2000
+++ Vanilla/ntserv/main.c Thu Oct 26 05:06:14 2000
@@ -150,15 +150,20 @@
}
starttime=time(NULL);
while (userVersion==0) {
+ time_t t;
/* Waiting for user to send his version number.
* We give him thirty seconds to do so...
*/
- if (starttime+30 < time(NULL)) {
+ if (isClientDead()) {
+ ERROR(2,("ntserv/main.c: disconnect waiting for version packet from %s\n", host));
+ exit(1);
+ }
+ if (starttime+30 < time(&t)) {
ERROR(2,("ntserv/main.c: no version packet received from %s\n",
host));
exit(1);
}
- socketPause();
+ socketPause(starttime+30-t);
readFromClient();
}
if (!checkVersion()) {
Index: Vanilla/ntserv/proto.h
diff -u Vanilla/ntserv/proto.h:1.4 Vanilla/ntserv/proto.h:1.5
--- Vanilla/ntserv/proto.h:1.4 Fri Mar 24 13:55:15 2000
+++ Vanilla/ntserv/proto.h Thu Oct 26 05:06:14 2000
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.4 2000/03/24 19:55:15 karthik Exp $
+/* $Id: proto.h,v 1.5 2000/10/26 10:06:14 xyzzy Exp $
*
* Function prototypes for externally accessed functions.
*/
@@ -182,7 +182,7 @@
void updateClient(void);
void sendClientPacket(void *);
void flushSockBuf(void);
-void socketPause(void);
+void socketPause(int);
int readFromClient(void);
int checkVersion(void);
void logEntry(void);
Index: Vanilla/ntserv/socket.c
diff -u Vanilla/ntserv/socket.c:1.27 Vanilla/ntserv/socket.c:1.28
--- Vanilla/ntserv/socket.c:1.27 Thu Jul 20 19:56:31 2000
+++ Vanilla/ntserv/socket.c Thu Oct 26 05:06:14 2000
@@ -1,4 +1,4 @@
-/* $Id: socket.c,v 1.27 2000/07/21 00:56:31 ahn Exp $
+/* $Id: socket.c,v 1.28 2000/10/26 10:06:14 xyzzy Exp $
*/
/*
@@ -899,12 +899,12 @@
fatMerge();
}
-void socketPause(void)
+void socketPause(int sec)
{
struct timeval timeout;
fd_set readfds;
- timeout.tv_sec=1;
+ timeout.tv_sec=sec;
timeout.tv_usec=0;
FD_ZERO(&readfds);
FD_SET(sock, &readfds);