Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit342cb65

Browse files
committed
Don't log incomplete startup packet if it's empty
This will stop logging cases where, for example, a monitor opens aconnection and immediately closes it. If the packet contains any data anincomplete packet will still be logged.Author: Tom LaneDiscussion:https://postgr.es/m/a1379a72-2958-1ed0-ef51-09a21219b155@2ndQuadrant.com
1 parentb172342 commit342cb65

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,17 +1899,34 @@ ProcessStartupPacket(Port *port, bool SSLdone)
18991899
MemoryContextoldcontext;
19001900

19011901
pq_startmsgread();
1902-
if (pq_getbytes((char*)&len,4)==EOF)
1902+
1903+
/*
1904+
* Grab the first byte of the length word separately, so that we can tell
1905+
* whether we have no data at all or an incomplete packet. (This might
1906+
* sound inefficient, but it's not really, because of buffering in
1907+
* pqcomm.c.)
1908+
*/
1909+
if (pq_getbytes((char*)&len,1)==EOF)
19031910
{
19041911
/*
1905-
* EOF after SSLdone probably means the client didn't like our
1906-
* response to NEGOTIATE_SSL_CODE. That's not an error condition, so
1907-
* don't clutter the log with a complaint.
1912+
* If we get no data at all, don't clutter the log with a complaint;
1913+
* such cases often occur for legitimate reasons. An example is that
1914+
* we might be here after responding to NEGOTIATE_SSL_CODE, and if the
1915+
* client didn't like our response, it'll probably just drop the
1916+
* connection. Service-monitoring software also often just opens and
1917+
* closes a connection without sending anything. (So do port
1918+
* scanners, which may be less benign, but it's not really our job to
1919+
* notice those.)
19081920
*/
1909-
if (!SSLdone)
1910-
ereport(COMMERROR,
1911-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
1912-
errmsg("incomplete startup packet")));
1921+
returnSTATUS_ERROR;
1922+
}
1923+
1924+
if (pq_getbytes(((char*)&len)+1,3)==EOF)
1925+
{
1926+
/* Got a partial length word, so bleat about that */
1927+
ereport(COMMERROR,
1928+
(errcode(ERRCODE_PROTOCOL_VIOLATION),
1929+
errmsg("incomplete startup packet")));
19131930
returnSTATUS_ERROR;
19141931
}
19151932

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp