Closed RavuAlHemio closed 8 years ago
Looks like my previous PR introduced a race condition that I then observed in the wild.
If the server responds with a PONG message quickly enough, the stopwatch swap-out performed after sending the PING message:
PONG
PING
_Connection.WriteLine(Rfc2812.Ping(_Connection.Address), Priority.Critical); _Connection.NextPingStopwatch.Stop(); _Connection.PingStopwatch.Reset(); _Connection.PingStopwatch.Start();
may come into a race with the stopwatch swap-out performed after receiving a PONG message:
switch (command) { // ... case "PONG": PingStopwatch.Stop(); NextPingStopwatch.Reset(); NextPingStopwatch.Start(); // ... break; }
Avoid this by moving the call sending the PING message until after the swap-out (top block).
Looks like my previous PR introduced a race condition that I then observed in the wild.
If the server responds with a
PONG
message quickly enough, the stopwatch swap-out performed after sending thePING
message:may come into a race with the stopwatch swap-out performed after receiving a PONG message:
Avoid this by moving the call sending the PING message until after the swap-out (top block).