public inbox for [email protected]  
help / color / mirror / Atom feed
Simplify signature of ProcessStartupPacket()
3+ messages / 2 participants
[nested] [flat]

* Simplify signature of ProcessStartupPacket()
@ 2026-05-15 06:22 Michael Paquier <[email protected]>
  2026-05-15 08:16 ` Re: Simplify signature of ProcessStartupPacket() Heikki Linnakangas <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Michael Paquier @ 2026-05-15 06:22 UTC (permalink / raw)
  To: Postgres hackers <[email protected]>; +Cc: Daniel Gustafsson <[email protected]>

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

From 54f411c36f4a5d67ce281a43ae2223ddc99e080b Mon Sep 17 00:00:00 2001
From: Michael Paquier <[email protected]>
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 <[email protected]>
---
 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 = {.ready_for_use = TIMESTAMP_MINUS_INFINITY};
 
 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_options);
 static void process_startup_packet_die(SIGNAL_ARGS);
@@ -292,7 +292,7 @@ BackendInitialize(ClientSocket *client_sock, CAC_state cac)
 	 * packet).
 	 */
 	if (status == STATUS_OK)
-		status = ProcessStartupPacket(port, false, false);
+		status = ProcessStartupPacket(port);
 
 	/*
 	 * 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 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.
  */
 static int
-ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
+ProcessStartupPacket(Port *port)
 {
 	int32		len;
 	char	   *buf = 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 = false;
+	ssl_done = false;
 
 retry:
 	pq_startmsgread();
-- 
2.54.0



Attachments:

  [text/plain] 0001-Simplify-signature-of-ProcessStartupPacket.patch (2.9K, 2-0001-Simplify-signature-of-ProcessStartupPacket.patch)
  download | inline diff:
From 54f411c36f4a5d67ce281a43ae2223ddc99e080b Mon Sep 17 00:00:00 2001
From: Michael Paquier <[email protected]>
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 <[email protected]>
---
 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 = {.ready_for_use = TIMESTAMP_MINUS_INFINITY};
 
 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_options);
 static void process_startup_packet_die(SIGNAL_ARGS);
@@ -292,7 +292,7 @@ BackendInitialize(ClientSocket *client_sock, CAC_state cac)
 	 * packet).
 	 */
 	if (status == STATUS_OK)
-		status = ProcessStartupPacket(port, false, false);
+		status = ProcessStartupPacket(port);
 
 	/*
 	 * 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 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.
  */
 static int
-ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
+ProcessStartupPacket(Port *port)
 {
 	int32		len;
 	char	   *buf = 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 = false;
+	ssl_done = false;
 
 retry:
 	pq_startmsgread();
-- 
2.54.0



  [application/pgp-signature] signature.asc (833B, 3-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Simplify signature of ProcessStartupPacket()
  2026-05-15 06:22 Simplify signature of ProcessStartupPacket() Michael Paquier <[email protected]>
@ 2026-05-15 08:16 ` Heikki Linnakangas <[email protected]>
  2026-05-15 08:33   ` Re: Simplify signature of ProcessStartupPacket() Michael Paquier <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Heikki Linnakangas @ 2026-05-15 08:16 UTC (permalink / raw)
  To: Michael Paquier <[email protected]>; Postgres hackers <[email protected]>; +Cc: Daniel Gustafsson <[email protected]>

On 15/05/2026 09:22, Michael Paquier wrote:
> 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.

+1. And I wouldn't mind committing that for v19 already.

- Heikki






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Simplify signature of ProcessStartupPacket()
  2026-05-15 06:22 Simplify signature of ProcessStartupPacket() Michael Paquier <[email protected]>
  2026-05-15 08:16 ` Re: Simplify signature of ProcessStartupPacket() Heikki Linnakangas <[email protected]>
@ 2026-05-15 08:33   ` Michael Paquier <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-05-15 08:33 UTC (permalink / raw)
  To: Heikki Linnakangas <[email protected]>; +Cc: Postgres hackers <[email protected]>; Daniel Gustafsson <[email protected]>

On Fri, May 15, 2026 at 11:16:38AM +0300, Heikki Linnakangas wrote:
> +1. And I wouldn't mind committing that for v19 already.

Thanks.  FWIW, I'm cool with v19 as well.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, 2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-05-15 08:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-05-15 06:22 Simplify signature of ProcessStartupPacket() Michael Paquier <[email protected]>
2026-05-15 08:16 ` Heikki Linnakangas <[email protected]>
2026-05-15 08:33   ` Michael Paquier <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox