mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
handle timeouts and server shutdown
This commit is contained in:
parent
8ac7a71e10
commit
d53190f345
1 changed files with 13 additions and 6 deletions
|
@ -111,6 +111,13 @@ server_free (void *_sv, void *unused)
|
||||||
free (sv);
|
free (sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
server_drop (server_t *sv)
|
||||||
|
{
|
||||||
|
Hash_Del (server_hash, sv->name);
|
||||||
|
Hash_Free (server_hash, sv);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
server_compare (const void *a, const void *b)
|
server_compare (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
|
@ -244,7 +251,8 @@ qtv_packet_f (server_t *sv)
|
||||||
save_signon (sv, &sub_message, start);
|
save_signon (sv, &sub_message, start);
|
||||||
break;
|
break;
|
||||||
case qtv_p_print:
|
case qtv_p_print:
|
||||||
qtv_printf ("%s\n", MSG_ReadString (net_message));
|
MSG_ReadByte (&sub_message);
|
||||||
|
qtv_printf ("%s\n", MSG_ReadString (&sub_message));
|
||||||
break;
|
break;
|
||||||
case qtv_p_reliable:
|
case qtv_p_reliable:
|
||||||
reliable = 1;
|
reliable = 1;
|
||||||
|
@ -299,6 +307,7 @@ server_handler (connection_t *con, void *object)
|
||||||
goto bail;
|
goto bail;
|
||||||
case qtv_disconnect:
|
case qtv_disconnect:
|
||||||
qtv_printf ("%s: disconnected\n", sv->name);
|
qtv_printf ("%s: disconnected\n", sv->name);
|
||||||
|
server_drop (sv);
|
||||||
break;
|
break;
|
||||||
case qtv_stringcmd:
|
case qtv_stringcmd:
|
||||||
sv_stringcmd (sv, net_message);
|
sv_stringcmd (sv, net_message);
|
||||||
|
@ -386,8 +395,7 @@ server_challenge (connection_t *con, void *object)
|
||||||
|
|
||||||
if (!qtv) {
|
if (!qtv) {
|
||||||
qtv_printf ("%s can't handle qtv.\n", sv->name);
|
qtv_printf ("%s can't handle qtv.\n", sv->name);
|
||||||
Hash_Del (server_hash, sv->name);
|
server_drop (sv);
|
||||||
Hash_Free (server_hash, sv);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,9 +553,8 @@ Server_Frame (void)
|
||||||
for (sv = servers; sv; sv = sv->next) {
|
for (sv = servers; sv; sv = sv->next) {
|
||||||
if (realtime - sv->netchan.last_received > sv_timeout->value) {
|
if (realtime - sv->netchan.last_received > sv_timeout->value) {
|
||||||
qtv_printf ("Server %s timed out\n", sv->name);
|
qtv_printf ("Server %s timed out\n", sv->name);
|
||||||
Hash_Del (server_hash, sv->name);
|
server_drop (sv);
|
||||||
Hash_Free (server_hash, sv);
|
return; // chain has changed, avoid segfaulting
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (sv->next_run && sv->next_run <= realtime) {
|
if (sv->next_run && sv->next_run <= realtime) {
|
||||||
sv->next_run = 0;
|
sv->next_run = 0;
|
||||||
|
|
Loading…
Reference in a new issue