diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2011-12-09 11:37:21 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2011-12-09 14:21:36 +0200 |
commit | 5d8a894e3095b2f602e901c19689f3176bf20543 (patch) | |
tree | b917c7012c64edb02883ac4e3a2ed59368cbc06e /src/backend/tcop/postgres.c | |
parent | d5f23af6bfbc454e86dd16e5c7a0bfc0cf6189d0 (diff) | |
download | postgresql-5d8a894e3095b2f602e901c19689f3176bf20543.tar.gz postgresql-5d8a894e3095b2f602e901c19689f3176bf20543.zip |
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.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 976a832135e..5bb16e010cc 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -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; |