mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
Don't log incomplete startup packet if it's empty
This will stop logging cases where, for example, a monitor opens a connection and immediately closes it. If the packet contains any data an incomplete packet will still be logged. Author: Tom Lane Discussion: https://postgr.es/m/a1379a72-2958-1ed0-ef51-09a21219b155@2ndQuadrant.com
This commit is contained in:
parent
b172342321
commit
342cb650e0
@ -1899,14 +1899,31 @@ ProcessStartupPacket(Port *port, bool SSLdone)
|
|||||||
MemoryContext oldcontext;
|
MemoryContext oldcontext;
|
||||||
|
|
||||||
pq_startmsgread();
|
pq_startmsgread();
|
||||||
if (pq_getbytes((char *) &len, 4) == EOF)
|
|
||||||
|
/*
|
||||||
|
* Grab the first byte of the length word separately, so that we can tell
|
||||||
|
* whether we have no data at all or an incomplete packet. (This might
|
||||||
|
* sound inefficient, but it's not really, because of buffering in
|
||||||
|
* pqcomm.c.)
|
||||||
|
*/
|
||||||
|
if (pq_getbytes((char *) &len, 1) == EOF)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* EOF after SSLdone probably means the client didn't like our
|
* If we get no data at all, don't clutter the log with a complaint;
|
||||||
* response to NEGOTIATE_SSL_CODE. That's not an error condition, so
|
* such cases often occur for legitimate reasons. An example is that
|
||||||
* don't clutter the log with a complaint.
|
* we might be here after responding to NEGOTIATE_SSL_CODE, and if the
|
||||||
|
* client didn't like our response, it'll probably just drop the
|
||||||
|
* connection. Service-monitoring software also often just opens and
|
||||||
|
* closes a connection without sending anything. (So do port
|
||||||
|
* scanners, which may be less benign, but it's not really our job to
|
||||||
|
* notice those.)
|
||||||
*/
|
*/
|
||||||
if (!SSLdone)
|
return STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pq_getbytes(((char *) &len) + 1, 3) == EOF)
|
||||||
|
{
|
||||||
|
/* Got a partial length word, so bleat about that */
|
||||||
ereport(COMMERROR,
|
ereport(COMMERROR,
|
||||||
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
||||||
errmsg("incomplete startup packet")));
|
errmsg("incomplete startup packet")));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user