thread-safety: strerror_r()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: thread-safety: strerror_r()
Date: 2024-09-02 19:45:03
Message-ID: daa87d79-c044-46c4-8458-8d77241ed7b0@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There are only a few (not necessarily thread-safe) strerror() calls in
the backend; most other potential users use %m in a format string.

In two cases, the reason for using strerror() was that we needed to
print the error message twice, and so errno has to be reset for the
second time. And/or some of this code is from before snprintf() gained
%m support. This can easily be simplified now.

The other is a workaround for OpenSSL that we have already handled in an
equivalent way in libpq.

(And there is one in postmaster.c, but that one is before forking.)

I think we can apply these patches now to check this off the list of
not-thread-safe functions to check.

Attachment Content-Type Size
0001-Remove-a-couple-of-strerror-calls.patch text/plain 1.6 KB
0002-Avoid-strerror.patch text/plain 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-09-02 19:56:40 Re: thread-safety: strerror_r()
Previous Message Andrei Lepikhov 2024-09-02 19:30:18 Re: query_id, pg_stat_activity, extended query protocol