mirror of
https://github.com/PretendoNetwork/nex-go.git
synced 2025-04-02 11:02:14 -04:00
fix(endpoint): Check PID invariant in FindConnectionByPID
An expected invariant of this system is that StateConnected connections also have a PID, and other states do *not* have a PID. While any code that breaks this invariant is buggy, we can still make FindConnectionByPID resilient to this to prevent that type of bug from taking the whole server down. That type of bug can still be detected through explicit testing of the Connections map.
This commit is contained in:
parent
fbe2b91e75
commit
9e5e0332b5
1 changed files with 1 additions and 1 deletions
|
@ -708,7 +708,7 @@ func (pep *PRUDPEndPoint) FindConnectionByPID(pid uint64) *PRUDPConnection {
|
|||
var connection *PRUDPConnection
|
||||
|
||||
pep.Connections.Each(func(discriminator string, pc *PRUDPConnection) bool {
|
||||
if pc.pid.Value() == pid {
|
||||
if pc.pid.Value() == pid && pc.ConnectionState == StateConnected {
|
||||
connection = pc
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue