File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 1717#include "fileio.h"
1818#include "hashmap.h"
1919#include "locale-util.h"
20+ #include "missing_syscall.h"
2021#include "path-util.h"
2122#include "set.h"
2223#include "string-table.h"
@@ -280,11 +281,6 @@ int locale_is_installed(const char *name) {
280281 return true;
281282}
282283
283- void init_gettext (void ) {
284- setlocale (LC_ALL , "" );
285- textdomain (GETTEXT_PACKAGE );
286- }
287-
288284bool is_locale_utf8 (void ) {
289285 static int cached_answer = -1 ;
290286 const char * set ;
@@ -303,6 +299,12 @@ bool is_locale_utf8(void) {
303299 } else if (r != - ENXIO )
304300 log_debug_errno (r , "Failed to parse $SYSTEMD_UTF8, ignoring: %m" );
305301
302+ /* This function may be called from libsystemd, and setlocale() is not thread safe. Assuming yes. */
303+ if (gettid () != raw_getpid ()) {
304+ cached_answer = true;
305+ goto out ;
306+ }
307+
306308 if (!setlocale (LC_ALL , "" )) {
307309 cached_answer = true;
308310 goto out ;
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ int locale_is_installed(const char *name);
3535
3636#define _ (String ) dgettext(GETTEXT_PACKAGE, String)
3737#define N_ (String ) String
38- void init_gettext (void );
3938
4039bool is_locale_utf8 (void );
4140
You can’t perform that action at this time.
0 commit comments