mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Cancel running query if it is detected that the connection to the client is
lost. The only way we detect that at the moment is when write() fails when we try to write to the socket. Florian Pflug with small changes by me, reviewed by Greg Jaskiewicz.
This commit is contained in:
@ -2823,6 +2823,18 @@ ProcessInterrupts(void)
|
||||
(errcode(ERRCODE_ADMIN_SHUTDOWN),
|
||||
errmsg("terminating connection due to administrator command")));
|
||||
}
|
||||
if (ClientConnectionLost)
|
||||
{
|
||||
QueryCancelPending = false; /* lost connection trumps QueryCancel */
|
||||
ImmediateInterruptOK = false; /* not idle anymore */
|
||||
DisableNotifyInterrupt();
|
||||
DisableCatchupInterrupt();
|
||||
/* don't send to client, we already know the connection to be dead. */
|
||||
whereToSendOutput = DestNone;
|
||||
ereport(FATAL,
|
||||
(errcode(ERRCODE_CONNECTION_FAILURE),
|
||||
errmsg("connection to client lost")));
|
||||
}
|
||||
if (QueryCancelPending)
|
||||
{
|
||||
QueryCancelPending = false;
|
||||
|
Reference in New Issue
Block a user