Vanilla Development Maling List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS update: Vanilla/ntserv
Date: Thursday March 4, 1999 @ 23:27
Author: cameron
Update of /home/netrek/cvsroot/Vanilla/ntserv
In directory cvs.castle.real-time.com:/var/tmp/cvs-serv6862
Modified Files:
daemonII.c getentry.c input.c socket.c
Log Message:
ghostbust fixes continued; reduce POUTFIT delay for KGHOST
****************************************
Index: Vanilla/ntserv/daemonII.c
diff -u Vanilla/ntserv/daemonII.c:1.10 Vanilla/ntserv/daemonII.c:1.11
--- Vanilla/ntserv/daemonII.c:1.10 Sun Feb 21 21:40:38 1999
+++ Vanilla/ntserv/daemonII.c Thu Mar 4 23:27:06 1999
@@ -635,9 +635,25 @@
nplayers = 0;
tcount[FED] = tcount[ROM] = tcount[KLI] = tcount[ORI] = 0;
for (i = status->active = 0, j = &players[i]; i < MAXPLAYER; i++, j++) {
+ int outfitdelay;
+
switch (j->p_status) {
case POUTFIT:
- if (++(j->p_ghostbuster) > OUTFITTIME) {
+
+ switch (j->p_whydead) {
+ case KQUIT:
+ case KGHOST:
+ case KPROVIDENCE:
+ case KBADBIN:
+ outfitdelay = GHOSTTIME;
+ break;
+ default:
+ outfitdelay = OUTFITTIME;
+ break;
+ }
+
+ if (++(j->p_ghostbuster) > outfitdelay) {
+ ERROR(4,("daemonII/udplayers: in POUTFIT too long\n"));
/* Force the player out of the game */
saveplayer(j);
if (j->p_process > 1) {
Index: Vanilla/ntserv/getentry.c
diff -u Vanilla/ntserv/getentry.c:1.2 Vanilla/ntserv/getentry.c:1.3
--- Vanilla/ntserv/getentry.c:1.2 Fri Feb 5 17:25:55 1999
+++ Vanilla/ntserv/getentry.c Thu Mar 4 23:27:07 1999
@@ -43,10 +43,10 @@
int i;
if (noressurect) exitGame();
- ERROR(2,("getentry: The client went away! (%s@%s)\n",
+ ERROR(2,("getentry: The client went away! (%s@%s)\n",
me->p_login,
me->p_monitor));
- ERROR(2,("I will attempt to resurrect him!\n"));
+ ERROR(2,("getentry: I will attempt to resurrect him!\n"));
/* UDP fail-safe */
commMode = COMM_TCP;
Index: Vanilla/ntserv/input.c
diff -u Vanilla/ntserv/input.c:1.3 Vanilla/ntserv/input.c:1.4
--- Vanilla/ntserv/input.c:1.3 Thu Feb 18 02:52:14 1999
+++ Vanilla/ntserv/input.c Thu Mar 4 23:27:07 1999
@@ -1,4 +1,7 @@
/* $Log: input.c,v $
+/* Revision 1.4 1999/03/05 05:27:07 cameron
+/* ghostbust fixes continued; reduce POUTFIT delay for KGHOST
+/*
/* Revision 1.3 1999/02/18 08:52:14 cameron
/* Ghostbust preliminary fixes
/*
@@ -119,10 +122,6 @@
sleep(1);
else
sleep(5);
- /* 18th Feb 1999, cameron@stl.dec.com, note that connectToClient may well
- pause for upwards of three minutes each time it is called if the remote
- host is a dial-up user whose IP address has not been reallocated yet.
- */
if (connectToClient(host, nextSocket)) break;
if (((i>=5) && testtime) ||
((i>=6) && (!testtime))) {
@@ -135,7 +134,7 @@
if (testtime) {
me->p_whydead = KQUIT;
me->p_status = PEXPLODE;
- ERROR(3,("User attempted to used old reserved.c"));
+ ERROR(3,("User attempted to used old reserved.c\n"));
new_warning(UNDEF,"Only RSA clients are valid. Please use a blessed one.");
}
else {
Index: Vanilla/ntserv/socket.c
diff -u Vanilla/ntserv/socket.c:1.3 Vanilla/ntserv/socket.c:1.4
--- Vanilla/ntserv/socket.c:1.3 Thu Feb 18 02:52:14 1999
+++ Vanilla/ntserv/socket.c Thu Mar 4 23:27:07 1999
@@ -1,4 +1,7 @@
/* $Log: socket.c,v $
+/* Revision 1.4 1999/03/05 05:27:07 cameron
+/* ghostbust fixes continued; reduce POUTFIT delay for KGHOST
+/*
/* Revision 1.3 1999/02/18 08:52:14 cameron
/* Ghostbust preliminary fixes
/*
@@ -53,6 +56,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -324,20 +328,21 @@
char *machine;
int port;
{
- int ns;
+ int ns, stat, derrno, derrnol;
struct sockaddr_in addr;
struct hostent *hp;
- /*int len,cc;*/
- /*int i;*/
+ struct timeval timeout;
+ fd_set writefds;
if (sock!=-1) {
shutdown(sock,2);
sock= -1;
}
- ERROR(3,("Connecting to %s through %d\n", machine, port));
+ ERROR(3,("connectToClient: host %s port %d\n", machine, port));
if ((ns=socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- ERROR(1,("I cannot create a socket\n"));
+ ERROR(1,("connectToClient: cannot create a socket\n"));
+ perror("socket");
exit(2);
}
@@ -348,7 +353,8 @@
addr.sin_addr.s_addr=remoteaddr;
} else if ((addr.sin_addr.s_addr = inet_addr(machine)) == -1) {
if ((hp = gethostbyname(machine)) == NULL) {
- ERROR(1,("I cannot get host name\n"));
+ ERROR(1,("connectToClient: cannot get host name\n"));
+ perror("connectToClient: gethostbyname");
close(ns);
exit(1);
} else {
@@ -363,11 +369,77 @@
plain isn't there any more. One solution is to set the socket to
non-blocking, issue the connect, then use select to timeout on a shorter
interval, and cancel the connect after that interval */
- if (connect(ns, &addr, sizeof(addr)) < 0) {
- ERROR(3,("I cannot connect through port %d\n", port));
+
+ /* set the socket non-blocking */
+ stat = ioctl(ns, FIONBIO, "in");
+ if (stat < 0) {
+ perror("connectToClient: ioctl: FIONBIO");
+ close(ns);
+ return(0);
+ }
+
+ /* start a connection attempt */
+ stat = connect(ns, &addr, sizeof(addr));
+ if (stat < 0 && errno != EINPROGRESS) {
+ ERROR(3,("connectToClient: connect failure to port %d\n", port));
+ if (errorlevel > 3) perror("connectToClient: connect");
+ ERROR(5,("connectToClient: errno %d\n", errno));
+ close(ns);
+ return(0);
+ }
+
+ /* wait a short time for it to complete */
+ timeout.tv_sec=10;
+ timeout.tv_usec=0;
+ FD_ZERO(&writefds);
+ FD_SET(ns, &writefds);
+ stat = select(32,0,&writefds,0,&timeout);
+ if (stat < 0) {
+ perror("connectToClient: select");
+ close(ns);
+ return(0);
+ }
+ if (stat == 0) {
+ ERROR(3,("connectToClient: connect timed out to port %d\n", port));
+ close(ns);
+ return(0);
+ }
+
+ /* read status of connect attempt */
+ derrnol = sizeof(derrno);
+ stat = getsockopt(ns, SOL_SOCKET, SO_ERROR, &derrno, &derrnol);
+ if (stat < 0) {
+ perror("connectToClient: getsockopt: SOL_SOCKET: SO_ERROR");
close(ns);
return(0);
}
+
+ switch (derrno) {
+ case 0:
+ break;
+ case ECONNREFUSED:
+ ERROR(3,("connectToClient: connect refused on port %d\n", port));
+ close(ns);
+ return(0);
+ case ENETUNREACH:
+ ERROR(3,("connectToClient: network unreachable on port %d\n", port));
+ close(ns);
+ return(0);
+ case ETIMEDOUT:
+ default:
+ if (errorlevel > 3) perror("connectToClient: connect");
+ close(ns);
+ return(0);
+ }
+
+ /* set the socket blocking */
+ stat = ioctl(ns, FIONBIO, "out");
+ if (stat < 0) {
+ perror("connectToClient: ioctl: FIONBIO");
+ close(ns);
+ return(0);
+ }
+
sock=ns;
initClientData();
testtime = -1;