FishNet icon indicating copy to clipboard operation
FishNet copied to clipboard

I Found an issue in FishNet.Transporting.Tugboat.Server.ServerSocket that need to be fixed right away

Open MohammedSitni opened this issue 3 years ago • 2 comments

I Found a bug in FishNet.Transporting.Tugboat.Server.ServerSocket that need to be fixed right away because it causes the server to halt completely:

        private NetPeer GetNetPeer(int connectionId, bool connectedOnly)
        {
            NetPeer peer = null;
            if (_server != null)
            {
// There is an or operator here in the original script
and this is a subtle bug that can pass a (-1) value some time.
to reproduce it you need to disconnect the client before the server try to disconnect the same client.
                if (connectionId >= 0  &&  /*was || before*/ _server.ConnectedPeersCount)
                    peer = _server.GetPeerById(connectionId);
                if (connectedOnly && peer != null && peer.ConnectionState != ConnectionState.Connected)
                    peer = null;
            }

            return peer;
        }

MohammedSitni avatar Oct 10 '22 01:10 MohammedSitni

Ah yep, that appears to be a typo. Fortunately I believe this could only be reproduced by manually passing in an invalid Id, so I wouldn't expect it to show up under ordinary usage.

It will be resolved in the next release, 2.5.5. Thanks again!

FirstGearGames avatar Oct 10 '22 14:10 FirstGearGames

Just an update to this, this is the new resolution. The change you made will break it for clients reconnecting. Also, _server.GetPeerById checks for -1 values. So you might have something else going on entirely.

        private NetPeer GetNetPeer(int connectionId, bool connectedOnly)
        {
            if (_server != null)
            {
                NetPeer peer = _server.GetPeerById(connectionId);
                if (connectedOnly && peer != null && peer.ConnectionState != ConnectionState.Connected)
                    peer = null;

                return peer;
            }
            else
            {
                return null;
            }
        }

FirstGearGames avatar Oct 11 '22 00:10 FirstGearGames