Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wNlwG-00131z-2t for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2026 06:22:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wNlwF-00GaI0-19 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2026 06:22:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wNlwE-00GaHr-1R for pgsql-hackers@lists.postgresql.org; Fri, 15 May 2026 06:22:23 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wNlwC-00000000enT-1Eh9 for pgsql-hackers@lists.postgresql.org; Fri, 15 May 2026 06:22:21 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 5F0C41D000A7; Fri, 15 May 2026 02:22:18 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 15 May 2026 02:22:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1778826138; x=1778912538; bh=G3fXf9NRZrgP7bftcr+DG5Wo+fPWsp6d fREhJUZ/f1I=; b=DeMeCEW4dddBaQUnp7Q6TYpkOrD/obcZo25T9rqzR+7gO6aw IolGre9Me3h392r3/VMLyiI+jnVjYORcN+Y8V3T71DyoMgbBfMqHsEiNzUiutrPH rBmRN3h4vRYfJUSmBBaQCP7YJVgq7MYyQj1eaBMwp/0qAHWbkFCKu1K16mezLTg4 DNiOKZ4MFw9DBYtHvToHW9KQx0SMrRtV6X6Bcv/fw3YnUryUGMDn/P0AduOLVr+V jrPyCI4iaN0Cw00lEIjx3fc6BUP39OsHkftA9i+Biyoc7P/uAGdObXJZRNL1y++i mzH2FAE/PpcyhPEOpSYUoY2ZUd5aEzg6QNfmdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778826138; x= 1778912538; bh=G3fXf9NRZrgP7bftcr+DG5Wo+fPWsp6dfREhJUZ/f1I=; b=B K9l5CifLVZgRiRgjMbhexXXj3wblSq6AI08ISXCkdFq04Vky6qwRBgX2AgAlYcoX 7n3cNW/4pthyVakMqfmkeTtbkSXqZWclL37r1s7tGJ/KWwl5YXQ3DCj2nfeKnMhA xiPLO/Tlqf/WgLJZgmrNA1vE/N1ce9SnzNJzGQXqJKGXuGYNfra+c4NPBb4kIF3x 8cBHQSYvz/AWR513jt+XPzwWnDj79xtiU64+kyPT3Mhmcp4C+sWiZ3Zv8nHvY+iN Mg82tsdrCczfOJYG1s5+JBBI73PJfkRXUoZVIOxNYNYvQilvBoWA4Gh8KbDv5kh2 M3gFIqdZnm6M8mNCr0CwA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduvdelieejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfggtggusehgtderredttddvnecu hfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqhhuih gvrhdrgiihiieqnecuggftrfgrthhtvghrnhepgeffkedufeeutdffteevgeduvdffvedu uefgudffgfelhfeludeghfejfeffteeinecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgs pghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphhgshhqlh dqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthht ohepuggrnhhivghlseihvghsqhhlrdhsvg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 15 May 2026 02:22:16 -0400 (EDT) Date: Fri, 15 May 2026 15:22:12 +0900 From: Michael Paquier To: Postgres hackers Cc: Daniel Gustafsson Subject: Simplify signature of ProcessStartupPacket() Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7iPItJjnAsiqRcex" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --7iPItJjnAsiqRcex Content-Type: multipart/mixed; boundary="8yd5u+yIvt9wtpEd" Content-Disposition: inline --8yd5u+yIvt9wtpEd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, In one of the recent patches committed into the tree (b63f25bddfeb), Daniel has come up with the suggestion to simplify ProcessStartupPacket() by removing its arguments "ssl_done" and "gss_done", as there is now only one callers of this routine. Please find attached a patch to do this cleanup. This is only for HEAD, material for v20. Thanks, -- Michael --8yd5u+yIvt9wtpEd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0001-Simplify-signature-of-ProcessStartupPacket.patch Content-Transfer-Encoding: quoted-printable =46rom 54f411c36f4a5d67ce281a43ae2223ddc99e080b Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Fri, 15 May 2026 15:21:31 +0900 Subject: [PATCH] Simplify signature of ProcessStartupPacket() There is now only one caller of ProcessStartupPacket(), so let's simplify the routine so as the GSS and SSL states are tracked inside it. If future callers are added, there is less guessing to do. Suggested-by: Daniel Gustafsson --- src/backend/tcop/backend_startup.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/backend/tcop/backend_startup.c b/src/backend/tcop/backend_= startup.c index a810e41a9040..25205cee0fa6 100644 --- a/src/backend/tcop/backend_startup.c +++ b/src/backend/tcop/backend_startup.c @@ -59,7 +59,7 @@ ConnectionTiming conn_timing =3D {.ready_for_use =3D TIME= STAMP_MINUS_INFINITY}; =20 static void BackendInitialize(ClientSocket *client_sock, CAC_state cac); static int ProcessSSLStartup(Port *port); -static int ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done); +static int ProcessStartupPacket(Port *port); static void ProcessCancelRequestPacket(Port *port, void *pkt, int pktlen); static void SendNegotiateProtocolVersion(List *unrecognized_protocol_optio= ns); static void process_startup_packet_die(SIGNAL_ARGS); @@ -292,7 +292,7 @@ BackendInitialize(ClientSocket *client_sock, CAC_state = cac) * packet). */ if (status =3D=3D STATUS_OK) - status =3D ProcessStartupPacket(port, false, false); + status =3D ProcessStartupPacket(port); =20 /* * If we're going to reject the connection due to database state, say so @@ -481,20 +481,27 @@ reject: * send anything to the client, which would typically be appropriate * if we detect a communications failure.) * - * Set ssl_done and/or gss_done when negotiation of an encrypted layer - * (currently, TLS or GSSAPI) is completed. A successful negotiation of ei= ther - * encryption layer sets both flags, but a rejected negotiation sets only = the - * flag for that layer, since the client may wish to try the other one. We - * should make no assumption here about the order in which the client may = make - * requests. */ static int -ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done) +ProcessStartupPacket(Port *port) { int32 len; char *buf =3D NULL; ProtocolVersion proto; MemoryContext oldcontext; + bool gss_done; + bool ssl_done; + + /* + * Set ssl_done and/or gss_done when negotiation of an encrypted layer + * (currently, TLS or GSSAPI) is completed. A successful negotiation of + * either encryption layer sets both flags, but a rejected negotiation + * sets only the flag for that layer, since the client may wish to try the + * other one. We should make no assumption here about the order in which + * the client may make requests. + */ + gss_done =3D false; + ssl_done =3D false; =20 retry: pq_startmsgread(); --=20 2.54.0 --8yd5u+yIvt9wtpEd-- --7iPItJjnAsiqRcex Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmoGu5QACgkQnvQgOdby QH0ezRAAn29jD5x2OrDxy3XUuwSc/WD/z+mhAP6/uhmUYdxUSPZA9d90ApEVz3Us 4DFq+UiVmZBkQWmOIXAYAEEFF3jJdyxkj8m7OwElJlnTOPyAnfVGjKPa5wK1l6jb CGUH5TtCo0DpV++u0E8Wi5ElEZR0V5TG9JqkOt7wszlyYEgo/qdlXWaov6+xs32F cSs8vFYjMuv82pTvX6NHwH4JBe4zst/xJVo0qQzg9HaaTqM4f3fXMv5Q1n1pMN9a WfTVCHDQ2aI0DvGLIvraV3GYK9d5SqYWrYo7OYWIgr8NgtXnaRLH0DVx+26czG4R VA5q6NfD/GnUXAsCAUwman8a74LovxvysTblzSBUKvMzQrAkaDVMP2QHMww5nd7k ozyfO33HnBYr51CWlvhItQiM8JdnVYuy8TJSHxbgRvfLNCYaPevDZ2Gl6LLBIgDk 1IrK7sVb5PNOc4a8IONxI7US5YJHzSffZLEHnpnMAnHxNMGh/loHLJbYaxerQBnW BwITv7BdMCsd1R4oePFaSZKv3NQ3SIa5xyT4Tg6gtgQlYXJGw23y/5dK7TR8VgtR AVjHExyMZuargdbTqTY2up6FRAZ7wYGQl4mFHvhLtmn3c7LY9pqWvD9TdIV8a5N7 y/Oi57M88M+kqjMzMUk5dKCkRIZ3/whEhbJT55MymRKCnYYjQvk= =wB9I -----END PGP SIGNATURE----- --7iPItJjnAsiqRcex--