internal IEnumerable<IServerResponseObject> ProcessBackendResponsesEnum(NpgsqlConnector context)
{
try
{
// Flush buffers to the wire.
context.Stream.Flush();
// Process commandTimeout behavior.
if ((context.Mediator.BackendCommandTimeout > 0) &&
(!CheckForContextSocketAvailability(context, SelectMode.SelectRead)))
{
// If timeout occurs when establishing the session with server then
// throw an exception instead of trying to cancel query. This helps to prevent loop as
// CancelRequest will also try to stablish a connection and sends commands.
if (!((this is NpgsqlStartupState || this is NpgsqlConnectedState)))
{
try
{
context.CancelRequest();
ProcessAndDiscardBackendResponses(context);
}
catch(Exception)
{
}
// We should have gotten an error from CancelRequest(). Whether we did or not, what we
// really have is a timeout exception, and that will be less confusing to the user than
// "operation cancelled by user" or similar, so whatever the case, that is what we'll throw.
// Changed message again to report about the two possible timeouts: connection or command
// as the establishment timeout only was confusing users when the timeout was a command timeout.
}
throw new NpgsqlException(resman.GetString("Exception_ConnectionOrCommandTimeout"));
}
switch (context.BackendProtocolVersion)
{
case ProtocolVersion.Version2:
return ProcessBackendResponses_Ver_2(context);
case ProtocolVersion.Version3:
return ProcessBackendResponses_Ver_3(context);
default:
throw new NpgsqlException(resman.GetString("Exception_UnknownProtocol"));
}
}
catch(ThreadAbortException)
{
try
{
context.CancelRequest();
context.Close();
}
catch {}
throw;
}
}