Skip to content

Commit 7c455f9

Browse files
committed
Ensure that sessions are pinged by default.
If sessions are being returned and borrowed quickly, the difference in ticks may be zero (because the system timer isn't high-resolution); the default value of ConnectionIdlePingTime=0 will now ping all sessions and users have to explicitly set it to a non-zero value to opt out.
1 parent f6fc0ca commit 7c455f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/MySqlConnector/Core/ConnectionPool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
7171
{
7272
reuseSession = await session.TryResetConnectionAsync(ConnectionSettings, ioBehavior, cancellationToken).ConfigureAwait(false);
7373
}
74-
else if ((unchecked((uint) Environment.TickCount) - session.LastReturnedTicks) > ConnectionSettings.ConnectionIdlePingTime)
74+
else if ((unchecked((uint) Environment.TickCount) - session.LastReturnedTicks) >= ConnectionSettings.ConnectionIdlePingTime)
7575
{
7676
reuseSession = await session.TryPingAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
7777
}

0 commit comments

Comments
 (0)