fix sv_ftp logic

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2117 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-03-14 02:54:54 +00:00
parent 05357f9dea
commit 2f26e1d12a
2 changed files with 21 additions and 8 deletions

View file

@ -17,6 +17,7 @@ int ftpfilelistsocket;
char *COM_ParseOut (char *data, char *out, int outlen);
static iwboolean ftpserverinitied = false;
iwboolean ftpserverfailed = false;
static int ftpserversocket;
@ -44,7 +45,7 @@ typedef struct FTPclient_s{
FTPclient_t *FTPclient;
void FTP_ServerInit(void)
qboolean FTP_ServerInit(void)
{
struct sockaddr_in address;
unsigned long _true = true;
@ -53,12 +54,16 @@ void FTP_ServerInit(void)
if ((ftpserversocket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
{
Sys_Error ("FTP_TCP_OpenSocket: socket:", strerror(qerrno));
Con_Printf ("FTP_TCP_OpenSocket: socket: %s\n", strerror(qerrno));
ftpserverfailed = true;
return false;
}
if (ioctlsocket (ftpserversocket, FIONBIO, &_true) == -1)
{
Sys_Error ("FTP_TCP_OpenSocket: ioctl FIONBIO:", strerror(qerrno));
ftpserverfailed = true;
return false;
}
address.sin_family = AF_INET;
@ -77,8 +82,10 @@ void FTP_ServerInit(void)
if( bind (ftpserversocket, (void *)&address, sizeof(address)) == -1)
{
Con_Printf("FTP_ServerInit: failed to bind socket\n");
closesocket(ftpserversocket);
return;
ftpserverfailed = true;
return false;
}
listen(ftpserversocket, 3);
@ -87,7 +94,7 @@ void FTP_ServerInit(void)
IWebPrintf("FTP server is running\n");
return;
return true;
}
void FTP_ServerShutdown(void)
@ -747,7 +754,7 @@ unsigned long _true = true;
if (!ftpserverinitied)
{
if (ftpserverwanted)
FTP_ServerInit();
return FTP_ServerInit();
return false;
}
else if (!ftpserverwanted)

View file

@ -68,8 +68,8 @@ int main(int argc, char **argv)
{
FTP_ServerRun(1);
HTTP_ServerPoll(1);
if (httpserverfailed)
Sys_Error("HTTP server failed");
if (ftpserverfailed || httpserverfailed)
Sys_Error("FTP/HTTP server failed");
Sleep(1);
}
}
@ -370,10 +370,16 @@ void IWebInit(void)
void IWebRun(void)
{
#ifdef WEBSERVER
extern qboolean httpserverfailed;
extern qboolean httpserverfailed, ftpserverfailed;
FTP_ServerRun(ftpserver.value!= 0);
HTTP_ServerPoll(httpserver.value!=0);
if (ftpserverfailed)
{
Con_Printf("FTP Server failed to load, setting %s to 0\n", ftpserver.name);
Cvar_SetValue(&ftpserver, 0);
ftpserverfailed = false;
}
if (httpserverfailed)
{
Con_Printf("HTTP Server failed to load, setting %s to 0\n", httpserver.name);