thread-safety: strerror_r()
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-09-02T19:45:03Z
Lists: pgsql-hackers
Attachments
- 0001-Remove-a-couple-of-strerror-calls.patch (text/plain) patch 0001
- 0002-Avoid-strerror.patch (text/plain) patch 0002
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.
Commits
-
Remove a couple of strerror() calls
- 82b07eba9e8b 18.0 landed