From: havoc Date: Thu, 3 Apr 2003 00:11:08 +0000 (+0000) Subject: fix for server dying when someone times out X-Git-Tag: xonotic-v0.1.0preview~6686 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c1bd2ffa056ccb144254a29313a98688e85e43f1;p=xonotic%2Fdarkplaces.git fix for server dying when someone times out some other cleanups (some Sys_Printf calls turned into Con_Printf, some comments added about DropClient calls) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2895 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/host.c b/host.c index 7b24461b..c5c783b5 100644 --- a/host.c +++ b/host.c @@ -425,22 +425,36 @@ void SV_DropClient (qboolean crash) int i; client_t *client; + Con_Printf ("Client \"%s\" dropped\n", host_client->name); + if (!crash) { // send any final messages (don't check for errors) -#if 1 - // LordHavoc: no opportunity for resending, so reliable is silly - MSG_WriteByte (&host_client->message, svc_disconnect); - NET_SendUnreliableMessage (host_client->netconnection, &host_client->message); -#else - if (NET_CanSendMessage (host_client->netconnection)) + if (host_client->netconnection && !host_client->netconnection->disconnected) { +#if 1 + // LordHavoc: no opportunity for resending, so reliable is silly MSG_WriteByte (&host_client->message, svc_disconnect); - NET_SendMessage (host_client->netconnection, &host_client->message); - } + NET_SendUnreliableMessage (host_client->netconnection, &host_client->message); +#else + if (NET_CanSendMessage (host_client->netconnection)) + { + MSG_WriteByte (&host_client->message, svc_disconnect); + NET_SendMessage (host_client->netconnection, &host_client->message); + } #endif + } } +// break the net connection + NET_Close (host_client->netconnection); + host_client->netconnection = NULL; + +// free the client (the body stays around) + host_client->active = false; + // note: don't clear name yet + net_activeconnections--; + if (sv.active && host_client->edict && host_client->spawned) // LordHavoc: don't call QC if server is dead (avoids recursive Host_Error in some mods when they run out of edicts) { // call the prog function for removing a client @@ -451,19 +465,11 @@ void SV_DropClient (qboolean crash) pr_global_struct->self = saveSelf; } - Sys_Printf ("Client %s removed\n",host_client->name); - -// break the net connection - NET_Close (host_client->netconnection); - host_client->netconnection = NULL; - -// free the client (the body stays around) - host_client->active = false; + // now clear name (after ClientDisconnect was called) host_client->name[0] = 0; host_client->old_frags = -999999; - net_activeconnections--; -// send notification to all clients + // send notification to all clients for (i=0, client = svs.clients ; iactive) @@ -547,7 +553,7 @@ void Host_ShutdownServer(qboolean crash) for (i=0, host_client = svs.clients ; iactive) - SV_DropClient(crash); + SV_DropClient(crash); // server shutdown // // clear structures diff --git a/host_cmd.c b/host_cmd.c index fc78cee4..4852da38 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1225,7 +1225,7 @@ void Host_Kick_f (void) SV_ClientPrintf ("Kicked by %s: %s\n", who, message); else SV_ClientPrintf ("Kicked by %s\n", who); - SV_DropClient (false); + SV_DropClient (false); // kicked } host_client = save; diff --git a/sv_main.c b/sv_main.c index 5941b55e..53702fee 100644 --- a/sv_main.c +++ b/sv_main.c @@ -1536,7 +1536,7 @@ void SV_SendClientMessages (void) // changes level if (host_client->message.overflowed) { - SV_DropClient (true); + SV_DropClient (true); // overflowed host_client->message.overflowed = false; continue; } diff --git a/sv_user.c b/sv_user.c index cc0a412a..152ec784 100644 --- a/sv_user.c +++ b/sv_user.c @@ -534,7 +534,7 @@ nextmsg: ret = NET_GetMessage (host_client->netconnection); if (ret == -1) { - Sys_Printf ("SV_ReadClientMessage: NET_GetMessage failed\n"); + Con_Printf ("SV_ReadClientMessage: NET_GetMessage failed\n"); return false; } if (!ret) @@ -550,7 +550,7 @@ nextmsg: if (msg_badread) { - Sys_Printf ("SV_ReadClientMessage: badread\n"); + Con_Printf ("SV_ReadClientMessage: badread\n"); return false; } @@ -571,7 +571,7 @@ nextmsg: goto nextmsg; default: - Sys_Printf ("SV_ReadClientMessage: unknown command char %i\n", cmd); + Con_Printf ("SV_ReadClientMessage: unknown command char %i\n", cmd); return false; case clc_nop: @@ -602,7 +602,7 @@ nextmsg: Cmd_ExecuteString (s, src_client); } else - Con_DPrintf("%s tried to %s\n", host_client->name, s); + Con_Printf("%s tried to %s\n", host_client->name, s); break; case clc_disconnect: @@ -642,8 +642,7 @@ void SV_RunClients (void) if (!SV_ReadClientMessage ()) { - // client misbehaved... - SV_DropClient (false); + SV_DropClient (false); // client misbehaved... continue; }