#13 missing checks to rare cases of nill players for slow connections

Closed
opened 6 months ago by mckaygerhard · 3 comments

i my server got this in some mods that have heavy usage of loop on connected players ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'ambience' in callback LuaABM::trigger()

that happened cos there's some loops around the connected players.. but in VERY HUGE amount of .. there's no so enought fast secuence to check if player still are valid..

so i made this:

index b378257..ca861c2 100644
--- a/init.lua
+++ b/init.lua
@@ -91,12 +91,16 @@ end
 
 -- setup table when player joins
 minetest.register_on_joinplayer(function(player)
-       playing[player:get_player_name()] = {music = -1}
+       if player ~= nil then
+               playing[player:get_player_name()] = {music = -1}
+       end
 end)
 
 -- remove table when player leaves
 minetest.register_on_leaveplayer(function(player)
-       playing[player:get_player_name()] = nil
+       if player ~= nil then
+               playing[player:get_player_name()] = nil
+       end
 end)
 
 
@@ -199,7 +203,9 @@ minetest.register_globalstep(function(dtime)
        -- loop through players
        for _, player in ipairs(minetest.get_connected_players()) do
 
-               player_name = player:get_player_name()
+               if player == nil then
+                       return
+               end
 
 --local t1 = os.clock()

i must made a pull request or you will respond in fast enought time? i'll wait for 1 day.

i my server got this in some mods that have heavy usage of loop on connected players `ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'ambience' in callback LuaABM::trigger()` that happened cos there's some loops around the connected players.. but in VERY HUGE amount of .. there's no so enought fast secuence to check if player still are valid.. so i made this: ``` index b378257..ca861c2 100644 --- a/init.lua +++ b/init.lua @@ -91,12 +91,16 @@ end -- setup table when player joins minetest.register_on_joinplayer(function(player) - playing[player:get_player_name()] = {music = -1} + if player ~= nil then + playing[player:get_player_name()] = {music = -1} + end end) -- remove table when player leaves minetest.register_on_leaveplayer(function(player) - playing[player:get_player_name()] = nil + if player ~= nil then + playing[player:get_player_name()] = nil + end end) @@ -199,7 +203,9 @@ minetest.register_globalstep(function(dtime) -- loop through players for _, player in ipairs(minetest.get_connected_players()) do - player_name = player:get_player_name() + if player == nil then + return + end --local t1 = os.clock() ``` i must made a pull request or you will respond in fast enought time? i'll wait for 1 day.
mckaygerhard commented 6 months ago
Poster
similar problem https://forum.minetest.net/viewtopic.php?p=302064#p302064 confirmed
TenPlus1 commented 6 months ago
Owner

Amended with changes.

Amended with changes.
mckaygerhard commented 6 months ago
Poster

you forgotten the reference.. i m putting here for others: f7d54237f6

so fast! Thanks!

you forgotten the reference.. i m putting here for others: https://notabug.org/TenPlus1/ambience/commit/f7d54237f60ad3d5649985c73dfa618bc605c5cb so fast! Thanks!
Sign in to join this conversation.
No Label
No Milestone
No assignee
2 Participants
Loading...
Cancel
Save
There is no content yet.