[ioquake3] 62/136: Refresh master server address cache every 24 hours
Simon McVittie
smcv at debian.org
Thu Jun 15 09:09:10 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit 973e0a7e9ce72bf9434aef0f6b2d31b5d12696af
Author: Zack Middleton <zack at cloemail.com>
Date: Tue May 30 17:57:49 2017 -0500
Refresh master server address cache every 24 hours
Resolve master server addresses every 24 hours instead of keeping
result forever. Don't clear sv_master[1-5] cvar if the address fails
to resolve; it might work later.
---
code/server/server.h | 6 ++++--
code/server/sv_main.c | 22 +++++++++-------------
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/code/server/server.h b/code/server/server.h
index 39d6f4d..7ffe66f 100644
--- a/code/server/server.h
+++ b/code/server/server.h
@@ -241,8 +241,10 @@ typedef struct {
int nextHeartbeatTime;
challenge_t challenges[MAX_CHALLENGES]; // to prevent invalid IPs from connecting
netadr_t redirectAddress; // for rcon return messages
-
- netadr_t authorizeAddress; // for rcon return messages
+#ifndef STANDALONE
+ netadr_t authorizeAddress; // authorize server address
+#endif
+ int masterResolveTime[MAX_MASTER_SERVERS]; // next svs.time that server should do dns lookup for master server
} serverStatic_t;
#define SERVER_MAXBANS 1024
diff --git a/code/server/sv_main.c b/code/server/sv_main.c
index 993910f..0dd8ad4 100644
--- a/code/server/sv_main.c
+++ b/code/server/sv_main.c
@@ -236,6 +236,7 @@ but not on every player enter or exit.
================
*/
#define HEARTBEAT_MSEC 300*1000
+#define MASTERDNS_MSEC 24*60*60*1000
void SV_MasterHeartbeat(const char *message)
{
static netadr_t adr[MAX_MASTER_SERVERS][2]; // [2] for v4 and v6 address for the same address string.
@@ -264,12 +265,12 @@ void SV_MasterHeartbeat(const char *message)
if(!sv_master[i]->string[0])
continue;
- // see if we haven't already resolved the name
- // resolving usually causes hitches on win95, so only
- // do it when needed
- if(sv_master[i]->modified || (adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD))
+ // see if we haven't already resolved the name or if it's been over 24 hours
+ // resolving usually causes hitches on win95, so only do it when needed
+ if (sv_master[i]->modified || svs.time > svs.masterResolveTime[i])
{
sv_master[i]->modified = qfalse;
+ svs.masterResolveTime[i] = svs.time + MASTERDNS_MSEC;
if(netenabled & NET_ENABLEV4)
{
@@ -304,16 +305,11 @@ void SV_MasterHeartbeat(const char *message)
else
Com_Printf( "%s has no IPv6 address.\n", sv_master[i]->string);
}
+ }
- if(adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD)
- {
- // if the address failed to resolve, clear it
- // so we don't take repeated dns hits
- Com_Printf("Couldn't resolve address: %s\n", sv_master[i]->string);
- Cvar_Set(sv_master[i]->name, "");
- sv_master[i]->modified = qfalse;
- continue;
- }
+ if(adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD)
+ {
+ continue;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git
More information about the Pkg-games-commits
mailing list