postgresql/src/include/tcop
Andres Freund 4fe384bd85 Process 'die' interrupts while reading/writing from the client socket.
Up to now it was impossible to terminate a backend that was trying to
send/recv data to/from the client when the socket's buffer was already
full/empty. While the send/recv calls itself might have gotten
interrupted by signals on some platforms, we just immediately retried.

That could lead to situations where a backend couldn't be terminated ,
after a client died without the connection being closed, because it
was blocked in send/recv.

The problem was far more likely to be hit when sending data than when
reading. That's because while reading a command from the client, and
during authentication, we processed interrupts immediately . That
primarily left COPY FROM STDIN as being problematic for recv.

Change things so that that we process 'die' events immediately when
the appropriate signal arrives. We can't sensibly react to query
cancels at that point, because we might loose sync with the client as
we could be in the middle of writing a message.

We don't interrupt writes if the write buffer isn't full, as indicated
by write() returning EWOULDBLOCK, as that would lead to fewer error
messages reaching clients.

Per discussion with Kyotaro HORIGUCHI and Heikki Linnakangas

Discussion: 20140927191243.GD5423@alap3.anarazel.de
2015-02-03 22:45:45 +01:00
..
dest.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
fastpath.h Be more careful to not lose sync in the FE/BE protocol. 2015-02-02 17:09:53 +02:00
pquery.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
tcopdebug.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
tcopprot.h Process 'die' interrupts while reading/writing from the client socket. 2015-02-03 22:45:45 +01:00
utility.h Update copyright for 2015 2015-01-06 11:43:47 -05:00