Re: contrib/sslinfo cleanup and OpenSSL errorhandling - Mailing list pgsql-hackers

From Andres Freund
Subject Re: contrib/sslinfo cleanup and OpenSSL errorhandling
Date
Msg-id 20201029234032.p3zdgvxwuc6svqxl@alap3.anarazel.de
Whole thread Raw
In response to contrib/sslinfo cleanup and OpenSSL errorhandling  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: contrib/sslinfo cleanup and OpenSSL errorhandling
Re: contrib/sslinfo cleanup and OpenSSL errorhandling
List pgsql-hackers
Hi,

Thanks for extracting these.

On 2020-10-29 23:48:57 +0100, Daniel Gustafsson wrote:>  
>  /*
> @@ -54,9 +53,16 @@ PG_FUNCTION_INFO_V1(ssl_version);
>  Datum
>  ssl_version(PG_FUNCTION_ARGS)
>  {
> -    if (MyProcPort->ssl == NULL)
> +    const char *version;
> +
> +    if (!MyProcPort->ssl_in_use)
> +        PG_RETURN_NULL();
> +
> +    version = be_tls_get_version(MyProcPort);
> +    if (version == NULL)
>          PG_RETURN_NULL();
> -    PG_RETURN_TEXT_P(cstring_to_text(SSL_get_version(MyProcPort->ssl)));
> +
> +    PG_RETURN_TEXT_P(cstring_to_text(version));
>  }

There's quite a few copies of this code that look exactly the same,
except for the be_tls_get_* call. Do you see a way to have fewer copies
of the same code?

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Deleting older versions in unique indexes to avoid page splits
Next
From: Peter Geoghegan
Date:
Subject: Re: Deleting older versions in unique indexes to avoid page splits