///<summary> /// This method is responsible to handle all protocol messages sent from the backend. /// It holds all the logic to do it. /// To exchange data, it uses a Mediator object from which it reads/writes information /// to handle backend requests. /// </summary> /// internal IEnumerable <IServerResponseObject> ProcessBackendResponsesEnum( NpgsqlConnector context, bool cancelRequestCalled) { try { // Process commandTimeout behavior. if ((context.Mediator.CommandTimeout > 0) && (!CheckForContextSocketAvailability(context))) { // 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 || cancelRequestCalled))) { try { context.CancelRequest(); foreach (IServerResponseObject obj in ProcessBackendResponsesEnum(context, true)) { if (obj is IDisposable) { (obj as IDisposable).Dispose(); } } } catch { } //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")); } return(ProcessBackendResponses_Ver_3(context)); } catch (ThreadAbortException) { try { context.CancelRequest(); context.Close(); } catch { } throw; } }
internal IEnumerable <IServerResponseObject> ProcessExistingBackendResponses(NpgsqlConnector context) { try { return(ProcessBackendResponses_Ver_3(context)); } catch (ThreadAbortException) { try { context.CancelRequest(); context.Close(); } catch { } throw; } }
/// <summary> /// Attempts to cancel the execution of a <see cref="Npgsql.NpgsqlCommand">NpgsqlCommand</see>. /// </summary> /// <remarks>This Method isn't implemented yet.</remarks> public override void Cancel() { try { // get copy for thread safety of null test NpgsqlConnector connector = Connector; if (connector != null) { connector.CancelRequest(); } } catch (IOException) { Connection.ClearPool(); } catch (NpgsqlException) { // Cancel documentation says the Cancel doesn't throw on failure } }
///<summary> /// This method is responsible to handle all protocol messages sent from the backend. /// It holds all the logic to do it. /// To exchange data, it uses a Mediator object from which it reads/writes information /// to handle backend requests. /// </summary> /// internal IEnumerable<IServerResponseObject> ProcessBackendResponsesEnum( NpgsqlConnector context, bool cancelRequestCalled) { try { // Process commandTimeout behavior. if ((context.Mediator.CommandTimeout > 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 || cancelRequestCalled))) { try { context.CancelRequest(); foreach (IServerResponseObject obj in ProcessBackendResponsesEnum(context, true)) { if (obj is IDisposable) { (obj as IDisposable).Dispose(); } } } catch { } //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")); } return ProcessBackendResponses_Ver_3(context); } catch (ThreadAbortException) { try { context.CancelRequest(); context.Close(); } catch { } throw; } }
internal IEnumerable<IServerResponseObject> ProcessExistingBackendResponses(NpgsqlConnector context) { try { return ProcessBackendResponses_Ver_3(context); } catch (ThreadAbortException) { try { context.CancelRequest(); context.Close(); } catch { } throw; } }