Re: BUG #18312: libpq: PQsetdbLogin() not thread-safe

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #18312: libpq: PQsetdbLogin() not thread-safe
Дата
Msg-id 3222816.1706897982@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #18312: libpq: PQsetdbLogin() not thread-safe  (Christian Maurer <c.maurer@gmx.at>)
Ответы Re: BUG #18312: libpq: PQsetdbLogin() not thread-safe  (Christian Maurer <c.maurer@gmx.at>)
Список pgsql-bugs
Christian Maurer <c.maurer@gmx.at> writes:
>> I wondered whether we needed to introduce a critical section
>> to prevent multiple threads from calling that concurrently,
>> even though its docs allege you shouldn't have to. Perhaps
>> it's thread-safe except on Windows?

> This would explain, why I could not reproduce the error on Red Hat Enterprise Linux.

Are you in a position to try a source-code patch?  The attached
is very quick-and-dirty, but if it resolves your problem then
we could turn it into something respectable.

            regards, tom lane

diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 47a28b0a3a..8906dae892 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -1243,12 +1243,17 @@ libpq_binddomain(void)
 #endif
         const char *ldir;
 
+        pglock_thread();
+
         /* No relocatable lookup here because the binary could be anywhere */
         ldir = getenv("PGLOCALEDIR");
         if (!ldir)
             ldir = LOCALEDIR;
         bindtextdomain(PG_TEXTDOMAIN("libpq"), ldir);
         already_bound = true;
+
+        pgunlock_thread();
+
 #ifdef WIN32
         SetLastError(save_errno);
 #else

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

Предыдущее
От: Christian Maurer
Дата:
Сообщение: Re: BUG #18312: libpq: PQsetdbLogin() not thread-safe
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #18325: Possible bug with plpgsql function + ALTER TABLE DROP COLUMN