1
0
Fork 0
forked from fte/fteqw

fix to sv_http logic

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2116 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-03-14 02:50:56 +00:00
parent 5bdbd0698e
commit 05357f9dea
2 changed files with 23 additions and 6 deletions

View file

@ -9,13 +9,14 @@
//FIXME: Before any admins use this for any serious usage, make the server send bits of file slowly.
static qboolean httpserverinitied = false;
qboolean httpserverfailed = false;
static int httpserversocket;
typedef enum {HTTP_WAITINGFORREQUEST,HTTP_SENDING} http_mode_t;
void HTTP_ServerInit(void)
qboolean HTTP_ServerInit(void)
{
struct sockaddr_in address;
unsigned long _true = true;
@ -24,12 +25,16 @@ void HTTP_ServerInit(void)
if ((httpserversocket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
{
Sys_Error ("HTTP_UDP_OpenSocket: socket:", strerror(qerrno));
Con_Printf ("HTTP_ServerInit: socket: %s\n", strerror(qerrno));
httpserverfailed = true;
return false;
}
if (ioctlsocket (httpserversocket, FIONBIO, &_true) == -1)
{
Sys_Error ("HTTP_UDP_OpenSocket: ioctl FIONBIO:", strerror(qerrno));
Con_Printf ("HTTP_ServerInit: ioctl FIONBIO: %s\n", strerror(qerrno));
httpserverfailed = true;
return false;
}
address.sin_family = AF_INET;
@ -51,7 +56,9 @@ void HTTP_ServerInit(void)
if( bind (httpserversocket, (void *)&address, sizeof(address)) == -1)
{
closesocket(httpserversocket);
return;
Con_Printf("HTTP_ServerInit: failed to bind to socket\n");
httpserverfailed = true;
return false;
}
listen(httpserversocket, 3);
@ -60,7 +67,7 @@ void HTTP_ServerInit(void)
IWebPrintf("HTTP server is running\n");
return;
return true;
}
void HTTP_ServerShutdown(void)
@ -481,7 +488,7 @@ qboolean HTTP_ServerPoll(qboolean httpserverwanted) //loop while true
if (!httpserverinitied)
{
if (httpserverwanted)
HTTP_ServerInit();
return HTTP_ServerInit();
return false;
}
else if (!httpserverwanted)

View file

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