Set timeout on HMS connections

(cherry picked from commit fcbe4e668f1ac79811d1ab2fb9cfd44729e56e93)
This commit is contained in:
James R 2020-05-15 13:20:40 -07:00
parent f32d91cc57
commit 0b5062d31c
3 changed files with 8 additions and 0 deletions

View File

@ -34,6 +34,11 @@ Documentation available here.
static void MasterServer_Debug_OnChange (void);
consvar_t cv_masterserver_timeout = {
"masterserver_timeout", "5", CV_SAVE, CV_Unsigned,
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
};
consvar_t cv_masterserver_debug = {
"masterserver_debug", "Off", CV_SAVE|CV_CALL, CV_OnOff,
MasterServer_Debug_OnChange, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
@ -165,6 +170,7 @@ HMS_connect (const char *format, ...)
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, cv_masterserver_timeout.value);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);

View File

@ -87,6 +87,7 @@ void AddMServCommands(void)
#ifndef NONET
CV_RegisterVar(&cv_masterserver);
CV_RegisterVar(&cv_masterserver_update_rate);
CV_RegisterVar(&cv_masterserver_timeout);
CV_RegisterVar(&cv_masterserver_debug);
CV_RegisterVar(&cv_servername);
COM_AddCommand("listserv", Command_Listserv_f);

View File

@ -66,6 +66,7 @@ typedef struct
extern consvar_t cv_masterserver, cv_servername;
extern consvar_t cv_masterserver_update_rate;
extern consvar_t cv_masterserver_timeout;
extern consvar_t cv_masterserver_debug;
// < 0 to not connect (usually -1) (offline mode)