Skip to content

Commit 50036e8

Browse files
committed
Add a check for end of client connection before expecting a password
response, to avoid noise in the server log.
1 parent 2f4759d commit 50036e8

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/backend/libpq/auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.55 2001/08/01 23:25:39 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.56 2001/08/07 10:44:13 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -554,7 +554,7 @@ recv_and_check_password_packet(Port *port)
554554
int32 len;
555555
int result;
556556

557-
if (pq_getint(&len, 4) == EOF)
557+
if (pq_eof() == EOF || pq_getint(&len, 4) == EOF)
558558
return STATUS_ERROR; /* client didn't want to send password */
559559
initStringInfo(&buf);
560560
pq_getstr(&buf);

src/backend/libpq/pqcomm.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
3030
* Portions Copyright (c) 1994, Regents of the University of California
3131
*
32-
* $Id: pqcomm.c,v 1.119 2001/08/05 01:22:16 tgl Exp $
32+
* $Id: pqcomm.c,v 1.120 2001/08/07 10:44:15 petere Exp $
3333
*
3434
*-------------------------------------------------------------------------
3535
*/
@@ -695,6 +695,26 @@ pq_flush(void)
695695
}
696696

697697

698+
/*
699+
* Return EOF if the connection has been broken, else 0.
700+
*/
701+
int
702+
pq_eof(void)
703+
{
704+
char x;
705+
int res;
706+
707+
res = recv(MyProcPort->sock, &x, 1, MSG_PEEK);
708+
709+
if (res == -1)
710+
fprintf(stderr, "pq_eof: recv() failed: %s\n", strerror(errno));
711+
else if (res == 0)
712+
return EOF;
713+
else
714+
return 0;
715+
}
716+
717+
698718
/* --------------------------------
699719
* Message-level I/O routines begin here.
700720
*

src/include/libpq/libpq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: libpq.h,v 1.44 2001/03/22 04:00:48 momjian Exp $
10+
* $Id: libpq.h,v 1.45 2001/08/07 10:44:16 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -65,6 +65,7 @@ extern int pq_getstring(StringInfo s);
6565
extern int pq_peekbyte(void);
6666
extern int pq_putbytes(const char *s, size_t len);
6767
extern int pq_flush(void);
68+
extern int pq_eof(void);
6869
extern int pq_putmessage(char msgtype, const char *s, size_t len);
6970
extern void pq_startcopyout(void);
7071
extern void pq_endcopyout(bool errorAbort);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy