Date: Wed, 9 Feb 2022 00:48:06 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 236a826c1478 - stable/13 - xlocale.c:init_key(): do not ignore errors from pthread_key_create() Message-ID: <202202090048.2190m6DA083666@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=236a826c1478fcec6f8037222564b3f1555483dc commit 236a826c1478fcec6f8037222564b3f1555483dc Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-02-02 17:23:55 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-02-09 00:42:45 +0000 xlocale.c:init_key(): do not ignore errors from pthread_key_create() (cherry picked from commit fcdf9d7de5363259e33be29bccc8b2b5dc091af8) --- lib/libc/locale/xlocale.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/libc/locale/xlocale.c b/lib/libc/locale/xlocale.c index 528403693ad4..e07568775394 100644 --- a/lib/libc/locale/xlocale.c +++ b/lib/libc/locale/xlocale.c @@ -117,11 +117,16 @@ static locale_t thread_local_locale; static void init_key(void) { + int error; - pthread_key_create(&locale_info_key, xlocale_release); - pthread_setspecific(locale_info_key, (void*)42); - if (pthread_getspecific(locale_info_key) == (void*)42) { - pthread_setspecific(locale_info_key, 0); + error = pthread_key_create(&locale_info_key, xlocale_release); + if (error == 0) { + pthread_setspecific(locale_info_key, (void*)42); + if (pthread_getspecific(locale_info_key) == (void*)42) { + pthread_setspecific(locale_info_key, 0); + } else { + fake_tls = 1; + } } else { fake_tls = 1; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202202090048.2190m6DA083666>