Skip to content

Commit fb527bd

Browse files
author
Gabriela Martinez
committed
Fixed Bug Fix for "Aborted connection" (MySQL Bug #80997, Oracle Bug # 23346197)
1 parent dc36a4f commit fb527bd

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- Fix for Nested transactions are not supported in Entity Framework (MySQL Bug #71502, Oracle Bug #22366266).
33
- Fix for EF5 and EF6 wrong SQL statement to set primary key (MySQL Bug 76292, Oracle Bug #20711384)
44
- Fixed problem where mysql.proc tables would not be used for metadata even though access was available (MySQL Bug #74116, Oracle Bug #20960373)
5+
- Fixed Fix for "Aborted connection" (MySQL Bug #80997, Oracle Bug # 23346197).
56

67
6.8.7
78
- Changed handshake process to use bytes instead of encoded strings.

Source/MySql.Data/Driver.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2004, 2015, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2004, 2016, Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -58,7 +58,7 @@ internal class Driver : IDisposable
5858
private bool firstResult;
5959
protected IDriver handler;
6060
internal MySqlDataReader reader;
61-
private bool disposeInProgress;
61+
private bool disposed;
6262

6363
/// <summary>
6464
/// For pooled connections, time when the driver was
@@ -532,20 +532,16 @@ public virtual void CloseQuery(MySqlConnection connection, int statementId)
532532
protected virtual void Dispose(bool disposing)
533533
{
534534
// Avoid cyclic calls to Dispose.
535-
if (disposeInProgress)
535+
if (disposed)
536536
return;
537-
538-
disposeInProgress = true;
539-
540537
try
541538
{
542-
ResetTimeout(1000);
543-
if (disposing)
544-
handler.Close(isOpen);
539+
ResetTimeout(1000);
540+
handler.Close(isOpen);
545541
// if we are pooling, then release ourselves
546542
if (connectionString.Pooling)
547-
MySqlPoolManager.RemoveConnection(this);
548-
}
543+
MySqlPoolManager.RemoveConnection(this);
544+
}
549545
catch (Exception)
550546
{
551547
if (disposing)
@@ -555,7 +551,7 @@ protected virtual void Dispose(bool disposing)
555551
{
556552
reader = null;
557553
isOpen = false;
558-
disposeInProgress = false;
554+
disposed = true;
559555
}
560556
}
561557

Tests/MySql.Data.Tests/MySqlConnectionTests.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,5 +1361,42 @@ public void SslOverrided()
13611361
}
13621362
}
13631363
}
1364+
1365+
1366+
1367+
/// <summary>
1368+
/// Fix for aborted connections MySQL bug 80997 OraBug 23346197
1369+
/// </summary>
1370+
[Fact]
1371+
public void MarkConnectionAsClosedProperlyWhenDisposing()
1372+
{
1373+
MySqlConnection con = new MySqlConnection(st.GetConnectionString(true));
1374+
con.Open();
1375+
MySqlCommand cmd = new MySqlCommand() { Connection = con };
1376+
cmd.CommandText = "Flush status"; // reset values
1377+
cmd.ExecuteNonQuery();
1378+
1379+
AppDomain appDomain = FullTrustSandbox.CreateFullTrustDomain();
1380+
FullTrustSandbox sandbox = (FullTrustSandbox)appDomain.CreateInstanceAndUnwrap(
1381+
typeof(FullTrustSandbox).Assembly.FullName,
1382+
typeof(FullTrustSandbox).FullName);
1383+
try
1384+
{
1385+
MySqlConnection connection = sandbox.TryOpenConnection("server=localhost;userid=root;pwd=;port=3305");
1386+
Assert.NotNull(connection);
1387+
Assert.True(connection.State == ConnectionState.Open);
1388+
}
1389+
finally
1390+
{
1391+
AppDomain.Unload(appDomain);
1392+
}
1393+
cmd = new MySqlCommand("show global status like 'aborted_clients'", con);
1394+
MySqlDataReader r = cmd.ExecuteReader();
1395+
r.Read();
1396+
int numClientsAborted = r.GetInt32(1);
1397+
r.Close();
1398+
Assert.Equal(0, numClientsAborted);
1399+
con.Close();
1400+
}
13641401
}
13651402
}

0 commit comments

Comments
 (0)