gai_strerror() is not thread-safe on Windows

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема gai_strerror() is not thread-safe on Windows
Дата
Msg-id CA+hUKGKz+F9d2PTiXwfYV7qJw+Wg2jzACgSDgPizUw7UG=i58A@mail.gmail.com
обсуждение исходный текст
Ответы Re: gai_strerror() is not thread-safe on Windows  (Thomas Munro <thomas.munro@gmail.com>)
Список pgsql-hackers
Hi,

Commit 5579388d removed a bunch of dead code, formerly needed for old
systems that lacked getaddrinfo() in the early days of IPv6.  We
already used the system getaddrinfo() via either configure-time tests
(Unix) or runtime tests (Windows using attempt-to-find-with-dlsym that
always succeeded on modern systems), so no modern system needed the
fallback code, except for one small detail:

getaddrinfo() has a companion function to spit out human readable
error messages, and although Windows has that too, it's not thread
safe[1].  libpq shouldn't call it, or else an unlucky multi-threaded
program might see an error message messed up by another thread.

Here's a patch to put that bit back.  It's simpler than before: the
original replacement had a bunch of #ifdefs for various historical
reasons, but now we can just handle the 8 documented EAI errors on
Windows.

Noticed while wondering why the list of symbols reported in bug #18219
didn't include gai_strerrorA.  That turned out to be because it is
static inline in ws2tcpip.h, and its definition set alarm bells
ringing.  Avoid.

[1] https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: connection timeout hint
Следующее
От: "Zhijie Hou (Fujitsu)"
Дата:
Сообщение: RE: Synchronizing slots from primary to standby