Skip to content

Commit

Permalink
Fix connection resiliency check (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Engel authored Nov 15, 2019
1 parent 1a0748e commit 6085573
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ internal Task ValidateAndReconnect(Action beforeDisconnect, int timeout)
{
}
// use Task.Factory.StartNew with state overload instead of Task.Run to avoid anonymous closure context capture in method scope and avoid the unneeded allocation
runningReconnect = Task.Factory.StartNew(state => ReconnectAsync((int)state), timeout, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
runningReconnect = Task.Factory.StartNew(state => ReconnectAsync((int)state), timeout, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default).Unwrap();
// if current reconnect is not null, somebody already started reconnection task - some kind of race condition
Debug.Assert(_currentReconnectionTask == null, "Duplicate reconnection tasks detected");
_currentReconnectionTask = runningReconnect;
Expand All @@ -1161,7 +1161,7 @@ internal Task ValidateAndReconnect(Action beforeDisconnect, int timeout)
OnError(SQL.CR_UnrecoverableServer(ClientConnectionId), true, null);
}
} // ValidateSNIConnection
} // sessionRecoverySupported
} // sessionRecoverySupported
} // connectRetryCount>0
}
else
Expand Down

0 comments on commit 6085573

Please sign in to comment.