Skip to content

Commit 2186e2f

Browse files
committed
Merge 0.69.4 into 1.0.
Conflicts: docs/content/overview/version-history.md src/Directory.Build.props src/MySqlConnector/MySqlConnection.cs
2 parents 2cbc4dd + 282ba13 commit 2186e2f

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

docs/content/overview/version-history.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Version History
2727
* Add `net5.0` target framework.
2828
* Reduce memory allocations when hashing passwords (during login).
2929

30+
### 0.69.4
31+
32+
* Fix connection pool leak when a failure (e.g., timeout) occurs on a connection: [#836](https://github.com/mysql-net/MySqlConnector/issues/836).
33+
3034
### 0.69.3
3135

3236
* Fix `Failed to read the result set.` error when using `MySqlBulkCopy`: [#780](https://github.com/mysql-net/MySqlConnector/issues/780).

src/MySqlConnector/MySqlConnection.cs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,6 @@ private void VerifyNotDisposed()
854854

855855
private Task CloseAsync(bool changeState, IOBehavior ioBehavior)
856856
{
857-
if (m_connectionState == ConnectionState.Closed)
858-
return Utility.CompletedTask;
859-
860857
// check fast path
861858
if (m_activeReader is null &&
862859
CurrentTransaction is null &&
@@ -924,31 +921,28 @@ private async Task DoCloseAsync(bool changeState, IOBehavior ioBehavior)
924921
}
925922
#endif
926923

927-
if (m_connectionState != ConnectionState.Closed)
924+
try
928925
{
929-
try
930-
{
931-
await CloseDatabaseAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
932-
}
933-
finally
926+
await CloseDatabaseAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
927+
}
928+
finally
929+
{
930+
if (m_session is not null)
934931
{
935-
if (m_session is not null)
932+
if (GetInitializedConnectionSettings().Pooling)
936933
{
937-
if (GetInitializedConnectionSettings().Pooling)
938-
{
939-
m_session.ReturnToPool();
940-
}
941-
else
942-
{
943-
await m_session.DisposeAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
944-
m_session.OwningConnection = null;
945-
}
946-
m_session = null;
934+
m_session.ReturnToPool();
947935
}
948-
949-
if (changeState)
950-
SetState(ConnectionState.Closed);
936+
else
937+
{
938+
await m_session.DisposeAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
939+
m_session.OwningConnection = null;
940+
}
941+
m_session = null;
951942
}
943+
944+
if (changeState)
945+
SetState(ConnectionState.Closed);
952946
}
953947
}
954948

0 commit comments

Comments
 (0)