| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | Daniel Gustafsson <daniel(at)yesql(dot)se>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: libpq OpenSSL and multithreading |
| Date: | 2025-07-02 11:44:55 |
| Message-ID: | 27dd8d8c-174c-4f66-b404-1e5d83c3e075@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 27.06.25 19:24, Daniel Gustafsson wrote:
> The OpenSSL code in libpq have two issues for multithreading: the verify_cb
> callback use a global variable to pass back error detail state and there is one
> use of strerror().
Slightly misleading title: This is actually about the *backend* libpq code.
> The attached fixes both, with no functional change, in order to pave the way
> for multithreading:
>
> * Rather than using a global variable the callback use a new member in the
> Port struct for passing the string, and the Port struct is in turn passed as
> private data in the SSL object
Couldn't this also be done by making that global variable thread-local?
But getting rid of it is even nicer.
> * The strerror call is replaced with a strerror_r call using the already
> existing errorbuffer
This one was already discussed some time ago at
<https://www.postgresql.org/message-id/flat/daa87d79-c044-46c4-8458-8d77241ed7b0%40eisentraut.org>:
> But the bigger issue is that the use of a static buffer makes
> this not thread-safe, so having it use strerror_r to fill that
> buffer is just putting lipstick on a pig.
It looks like your patch doesn't address that?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashutosh Bapat | 2025-07-02 12:20:18 | Re: Using failover slots for PG-non_PG logical replication |
| Previous Message | Ashutosh Bapat | 2025-07-02 11:37:28 | Re: Adding basic NUMA awareness |