mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 19:02:45 +00:00
Kick clients if they take too long to download a Lua file
This commit is contained in:
parent
b6e5837161
commit
854e43ea7c
2 changed files with 18 additions and 0 deletions
|
@ -570,6 +570,7 @@ static void SV_PrepareSendLuaFileToNextNode(void)
|
|||
I_Error("Failed to send a PT_SENDINGLUAFILE packet\n"); // !!! Todo: Handle failure a bit better lol
|
||||
|
||||
luafiletransfers->nodestatus[i] = LFTNS_ASKED;
|
||||
luafiletransfers->nodetimeouts[i] = I_GetTime() + 30 * TICRATE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -930,6 +931,22 @@ void FileSendTicker(void)
|
|||
filetx_t *f;
|
||||
INT32 packetsent, ram, i, j;
|
||||
|
||||
// If someone is taking too long to download, kick them with a timeout
|
||||
// to prevent blocking the rest of the server...
|
||||
if (luafiletransfers)
|
||||
{
|
||||
for (i = 1; i < MAXNETNODES; i++)
|
||||
{
|
||||
luafiletransfernodestatus_t status = luafiletransfers->nodestatus[i];
|
||||
|
||||
if (status != LFTNS_NONE && status != LFTNS_WAITING && status != LFTNS_SENT
|
||||
&& I_GetTime() > luafiletransfers->nodetimeouts[i])
|
||||
{
|
||||
Net_ConnectionTimeout(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!filestosend) // No file to send
|
||||
return;
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ typedef struct luafiletransfer_s
|
|||
INT32 id; // Callback ID
|
||||
boolean ongoing;
|
||||
luafiletransfernodestatus_t nodestatus[MAXNETNODES];
|
||||
tic_t nodetimeouts[MAXNETNODES];
|
||||
struct luafiletransfer_s *next;
|
||||
} luafiletransfer_t;
|
||||
|
||||
|
|
Loading…
Reference in a new issue