Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
854e43ea
Commit
854e43ea
authored
4 years ago
by
LJ Sonic
Browse files
Options
Downloads
Patches
Plain Diff
Kick clients if they take too long to download a Lua file
parent
b6e58371
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1435
Prevent a single client from blocking Lua file transfers
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/d_netfil.c
+17
-0
17 additions, 0 deletions
src/d_netfil.c
src/d_netfil.h
+1
-0
1 addition, 0 deletions
src/d_netfil.h
with
18 additions
and
0 deletions
src/d_netfil.c
+
17
−
0
View file @
854e43ea
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
src/d_netfil.h
+
1
−
0
View file @
854e43ea
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment