1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

Centralize libpq's low-level code for dropping a connection.

Create an internal function pqDropConnection that does the physical socket
close and cleans up closely-associated state.  This removes a bunch of ad
hoc, not always consistent closure code.  The ulterior motive is to have a
single place to wait for a spawned child backend to exit, but this seems
like good cleanup even if that never happens.

I went back and forth on whether to include "conn->status = CONNECTION_BAD"
in pqDropConnection's actions, but for the moment decided not to.  Only a
minority of the call sites actually want that, and in any case it's
arguable that conn->status is slightly higher-level state, and thus not
part of this function's purview.
This commit is contained in:
Tom Lane
2012-09-07 16:02:23 -04:00
parent dda589c96b
commit 210eb9b743
4 changed files with 38 additions and 67 deletions

View File

@ -780,11 +780,8 @@ retry4:
* has been set already.
*/
definitelyFailed:
pqDropConnection(conn);
conn->status = CONNECTION_BAD; /* No more connection to backend */
pqsecure_close(conn);
closesocket(conn->sock);
conn->sock = -1;
return -1;
}