aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-connect.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2001-07-06 17:58:53 +0000
committerPeter Eisentraut <peter_e@gmx.net>2001-07-06 17:58:53 +0000
commite77aaade349e3947a55c41f07eb80c4f5260ada4 (patch)
tree16fd7907ec02d35eb45acbf6d6cee440cb9be9ec /src/interfaces/libpq/fe-connect.c
parent9981b0f9effd149ebf012d52db50d0e2d3cd513f (diff)
downloadpostgresql-e77aaade349e3947a55c41f07eb80c4f5260ada4.tar.gz
postgresql-e77aaade349e3947a55c41f07eb80c4f5260ada4.zip
Repair libpq to follow protocol by not sending Terminate messages before
the startup exchange is complete. Also make sure that packets defined as single bytes aren't sent with a trailing '\0'.
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r--src/interfaces/libpq/fe-connect.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 18770f49f51..7fda1a81f5e 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.164 2001/03/31 23:14:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.165 2001/07/06 17:58:53 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1409,6 +1409,7 @@ keep_going: /* We will come back to here until there
if (areq == AUTH_REQ_OK)
{
/* We are done with authentication exchange */
+ conn->startup_complete = TRUE;
conn->status = CONNECTION_AUTH_OK;
/*
@@ -1909,6 +1910,7 @@ makeEmptyPGconn(void)
freePGconn(conn);
conn = NULL;
}
+ conn->startup_complete = FALSE;
return conn;
}
@@ -1972,7 +1974,9 @@ freePGconn(PGconn *conn)
static void
closePGconn(PGconn *conn)
{
- if (conn->sock >= 0)
+ /* Note that the protocol doesn't allow us to send Terminate
+ messages during the startup phase. */
+ if (conn->sock >= 0 && conn->startup_complete)
{
/*
@@ -1981,8 +1985,8 @@ closePGconn(PGconn *conn)
* avoid getting SIGPIPE'd if the connection were already closed.
* Now we rely on pqFlush to avoid the signal.
*/
- (void) pqPuts("X", conn);
- (void) pqFlush(conn);
+ pqPutc('X', conn);
+ pqFlush(conn);
}
/*