From 210eb9b743c0645df05e5c8be4490ba4f09fc871 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 7 Sep 2012 16:02:23 -0400 Subject: 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. --- src/interfaces/libpq/fe-protocol3.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/interfaces/libpq/fe-protocol3.c') diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c index d289f82285f..c605bcd734c 100644 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@ -430,9 +430,7 @@ handleSyncLoss(PGconn *conn, char id, int msgLength) pqSaveErrorResult(conn); conn->asyncStatus = PGASYNC_READY; /* drop out of GetResult wait loop */ - pqsecure_close(conn); - closesocket(conn->sock); - conn->sock = -1; + pqDropConnection(conn); conn->status = CONNECTION_BAD; /* No more connection to backend */ } -- cgit v1.2.3