avoid-concurrent-bindtextdomain-calls-wip.patch

text/x-diff

Filename: avoid-concurrent-bindtextdomain-calls-wip.patch
Type: text/x-diff
Part: 0
Message: Re: BUG #18312: libpq: PQsetdbLogin() not thread-safe

Patch

Format: unified
File+
src/interfaces/libpq/fe-misc.c 5 0
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