Skip to content

Commit 2d81cf4

Browse files
committed
Remove CancellationToken from methods that don't use it.
These methods are canceled out-of-band by issuing a "KILL QUERY" command to the server that cancels the current query gracefully (rather than closing an open Socket).
1 parent fde4f56 commit 2d81cf4

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/MySqlConnector/MySqlClient/CommandExecutors/TextCommandExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public virtual async Task<DbDataReader> ExecuteReaderAsync(string commandText, M
6565
try
6666
{
6767
await m_command.Connection.Session.SendAsync(payload, ioBehavior, CancellationToken.None).ConfigureAwait(false);
68-
return await MySqlDataReader.CreateAsync(m_command, behavior, ioBehavior, CancellationToken.None).ConfigureAwait(false);
68+
return await MySqlDataReader.CreateAsync(m_command, behavior, ioBehavior).ConfigureAwait(false);
6969
}
7070
catch (MySqlException ex) when (ex.Number == (int) MySqlErrorCode.QueryInterrupted && cancellationToken.IsCancellationRequested)
7171
{

src/MySqlConnector/MySqlClient/MySqlDataReader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private async Task<ResultSet> ScanResultSetAsyncAwaited(IOBehavior ioBehavior, R
112112
{
113113
try
114114
{
115-
m_resultSetBuffered = await resultSet.ReadResultSetHeaderAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
115+
m_resultSetBuffered = await resultSet.ReadResultSetHeaderAsync(ioBehavior).ConfigureAwait(false);
116116
return m_resultSetBuffered;
117117
}
118118
catch (MySqlException ex) when (ex.Number == (int) MySqlErrorCode.QueryInterrupted)
@@ -224,17 +224,17 @@ protected override void Dispose(bool disposing)
224224
internal MySqlConnection Connection => Command?.Connection;
225225
internal MySqlSession Session => Command?.Connection.Session;
226226

227-
internal static async Task<MySqlDataReader> CreateAsync(MySqlCommand command, CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken)
227+
internal static async Task<MySqlDataReader> CreateAsync(MySqlCommand command, CommandBehavior behavior, IOBehavior ioBehavior)
228228
{
229229
var dataReader = new MySqlDataReader(command, behavior);
230230
command.Connection.Session.SetActiveReader(dataReader);
231231

232232
try
233233
{
234-
await dataReader.ReadFirstResultSetAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
234+
await dataReader.ReadFirstResultSetAsync(ioBehavior).ConfigureAwait(false);
235235
if (command.Connection.BufferResultSets)
236236
{
237-
while (await dataReader.BufferNextResultAsync(ioBehavior, cancellationToken).ConfigureAwait(false) != null)
237+
while (await dataReader.BufferNextResultAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false) != null)
238238
{
239239
}
240240
}
@@ -252,9 +252,9 @@ internal static async Task<MySqlDataReader> CreateAsync(MySqlCommand command, Co
252252
}
253253
}
254254

255-
internal async Task ReadFirstResultSetAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
255+
internal async Task ReadFirstResultSetAsync(IOBehavior ioBehavior)
256256
{
257-
m_resultSet = await new ResultSet(this).ReadResultSetHeaderAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
257+
m_resultSet = await new ResultSet(this).ReadResultSetHeaderAsync(ioBehavior).ConfigureAwait(false);
258258
ActivateResultSet(m_resultSet);
259259
m_resultSetBuffered = m_resultSet;
260260
}

src/MySqlConnector/MySqlClient/Results/ResultSet.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public ResultSet(MySqlDataReader dataReader)
1616
DataReader = dataReader;
1717
}
1818

19-
public async Task<ResultSet> ReadResultSetHeaderAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
19+
public async Task<ResultSet> ReadResultSetHeaderAsync(IOBehavior ioBehavior)
2020
{
2121
// ResultSet can be re-used, so initialize everything
2222
BufferState = ResultSetState.None;
@@ -34,7 +34,7 @@ public async Task<ResultSet> ReadResultSetHeaderAsync(IOBehavior ioBehavior, Can
3434
{
3535
while (true)
3636
{
37-
var payload = await Session.ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
37+
var payload = await Session.ReceiveReplyAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
3838

3939
var firstByte = payload.HeaderByte;
4040
if (firstByte == OkPayload.Signature)
@@ -63,7 +63,7 @@ public async Task<ResultSet> ReadResultSetHeaderAsync(IOBehavior ioBehavior, Can
6363
while ((byteCount = await stream.ReadAsync(readBuffer, 0, readBuffer.Length).ConfigureAwait(false)) > 0)
6464
{
6565
payload = new PayloadData(new ArraySegment<byte>(readBuffer, 0, byteCount));
66-
await Session.SendReplyAsync(payload, ioBehavior, cancellationToken).ConfigureAwait(false);
66+
await Session.SendReplyAsync(payload, ioBehavior, CancellationToken.None).ConfigureAwait(false);
6767
}
6868
}
6969
}
@@ -73,7 +73,7 @@ public async Task<ResultSet> ReadResultSetHeaderAsync(IOBehavior ioBehavior, Can
7373
ReadResultSetHeaderException = new MySqlException("Error during LOAD DATA LOCAL INFILE", ex);
7474
}
7575

76-
await Session.SendReplyAsync(EmptyPayload.Create(), ioBehavior, cancellationToken).ConfigureAwait(false);
76+
await Session.SendReplyAsync(EmptyPayload.Create(), ioBehavior, CancellationToken.None).ConfigureAwait(false);
7777
}
7878
else
7979
{
@@ -85,11 +85,11 @@ public async Task<ResultSet> ReadResultSetHeaderAsync(IOBehavior ioBehavior, Can
8585

8686
for (var column = 0; column < ColumnDefinitions.Length; column++)
8787
{
88-
payload = await Session.ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
88+
payload = await Session.ReceiveReplyAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
8989
ColumnDefinitions[column] = ColumnDefinitionPayload.Create(payload);
9090
}
9191

92-
payload = await Session.ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
92+
payload = await Session.ReceiveReplyAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false);
9393
EofPayload.Create(payload);
9494

9595
LastInsertId = -1;

0 commit comments

Comments
 (0)