bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Library initialization with gettext is not thread-safe


From: Bruno Haible
Subject: Re: Library initialization with gettext is not thread-safe
Date: Fri, 08 Jul 2022 07:33:25 +0200

Vivien Kraus wrote:
> The Gettext manual section 4.10 Preparing Library Sources shows how to
> lazily initialize gettext for a library. However, if multiple threads
> call create_foo (in the manual example) before it has been initialized,
> then there is a race condition. How do you solve it?

The 'bindtextdomain' function is multi-thread safe and idempotent.
Therefore the libfoo_initialize function [1] is multi-thread safe and
idempotent as well. That is, in the case that multiple threads call
create_foo at the same time, libfoo_initialize may be called several
times, but this is harmless.

No?

Bruno

[1] https://www.gnu.org/software/gettext/manual/html_node/Libraries.html






reply via email to

[Prev in Thread] Current Thread [Next in Thread]