Skip to content

Commit

Permalink
tried to fix null reference exception in websocket server middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryjiang committed May 11, 2024
1 parent c2267d2 commit 90b389b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/SuperSocket.WebSocket.Server/WebSocketServerMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ public override void Start(IServer server)

public override void Shutdown(IServer server)
{
_sessionContainerMiddleware = null;

var checkTimer = _checkingTimer;
_checkingTimer = null;
checkTimer.Change(Timeout.Infinite, Timeout.Infinite);
checkTimer.Dispose();

_sessionContainerMiddleware = null;
if (checkTimer == null)
return;

if (Interlocked.CompareExchange(ref _checkingTimer, null, checkTimer) == checkTimer)
{
checkTimer.Change(Timeout.Infinite, Timeout.Infinite);
checkTimer.Dispose();
}
}

public override ValueTask<bool> RegisterSession(IAppSession session)
Expand Down

0 comments on commit 90b389b

Please sign in to comment.