|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: package/.../musl/0001-make-h_errno-thread-local.patch
|
|
# Copyright (C) 2020 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This patch file is dual-licensed. It is available under the license the
|
|
# patched project is licensed under, as long as it is an OpenSource license
|
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
|
# of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
# version.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
From 9d0b8b92a508c328e7eac774847f001f80dfb5ff Mon Sep 17 00:00:00 2001
|
|
From: Rich Felker <dalias@aerifal.cx>
|
|
Date: Mon, 24 Aug 2020 21:38:49 -0400
|
|
Subject: [PATCH] make h_errno thread-local
|
|
|
|
the framework to do this always existed but it was deemed unnecessary
|
|
because the only [ex-]standard functions using h_errno were not
|
|
thread-safe anyway. however, some of the nonstandard res_* functions
|
|
are also supposed to set h_errno to indicate the cause of error, and
|
|
were unable to do so because it was not thread-safe. this change is a
|
|
prerequisite for fixing them.
|
|
---
|
|
src/internal/pthread_impl.h | 1 +
|
|
src/network/h_errno.c | 6 ++----
|
|
2 files changed, 3 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
|
|
index 5742dfc5..5749a336 100644
|
|
--- a/src/internal/pthread_impl.h
|
|
+++ b/src/internal/pthread_impl.h
|
|
@@ -43,6 +43,7 @@ struct pthread {
|
|
long off;
|
|
volatile void *volatile pending;
|
|
} robust_list;
|
|
+ int h_errno_val;
|
|
volatile int timer_id;
|
|
locale_t locale;
|
|
volatile int killlock[1];
|
|
diff --git a/src/network/h_errno.c b/src/network/h_errno.c
|
|
index 4f700cea..8677a92b 100644
|
|
--- a/src/network/h_errno.c
|
|
+++ b/src/network/h_errno.c
|
|
@@ -1,9 +1,7 @@
|
|
#include <netdb.h>
|
|
-
|
|
-#undef h_errno
|
|
-int h_errno;
|
|
+#include "pthread_impl.h"
|
|
|
|
int *__h_errno_location(void)
|
|
{
|
|
- return &h_errno;
|
|
+ return &__pthread_self()->h_errno_val;
|
|
}
|
|
--
|
|
2.28.0
|
|
|