libpq OpenSSL and multithreading

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: libpq OpenSSL and multithreading
Date: 2025-06-27 17:24:28
Message-ID: 353226C7-97A1-4507-A380-36AA92983AE6@yesql.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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().

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
* The strerror call is replaced with a strerror_r call using the already
existing errorbuffer

These were tested on OpenSSL 1.1.1 through 3.5. Parking this in the next
commitfest.

--
Daniel Gustafsson

Attachment Content-Type Size
0001-libpq-Fix-multithreading-issues-in-the-OpenSSL-suppo.patch application/octet-stream 4.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-06-27 17:33:26 Re: pgsql: Introduce pg_shmem_allocations_numa view
Previous Message Tomas Vondra 2025-06-27 16:41:30 Re: NUMA shared memory interleaving