libX11/U_0001-Add-XFreeThreads-function.patch
Stefan Dirsch e17a686d68 - U_0001-Add-XFreeThreads-function.patch
U_0002-Don-t-use-pragma-inside-a-function-it-breaks-compili.patch
  U_0003-Fix-797755-Allow-X-IfEvent-to-reenter-libX11.patch
  U_0004-Indentation-fixes-around-recent-dpy-in_ifevent-chang.patch
  U_0005-ChkIfEv.c-fix-wrong-handling-of-dpy-in_ifevent.patch
  * adding all patches since 1.8.2 release in order to try fixing
    regressions after introducing thread safety constructor with
    1.8.1 (boo#1205778, boo#1205818)
- supersedes U_Fix-797755-Allow-X-IfEvent-to-reenter-libX11.patch
- re-enabled thread safe constructor

OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/libX11?expand=0&rev=91
2022-12-03 10:31:33 +00:00

109 lines
2.4 KiB
Diff

From 696d19d5db7bcb1c1f582c2b1846520e7e0870cb Mon Sep 17 00:00:00 2001
From: Oliver <halting@riseup.net>
Date: Fri, 11 Nov 2022 17:04:00 +0000
Subject: [PATCH 1/5] Add XFreeThreads function.
---
include/X11/Xlib.h | 4 ++++
man/XInitThreads.man | 8 +++++++-
src/globals.c | 6 ++++++
src/locking.c | 23 +++++++++++++++++++++++
4 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/include/X11/Xlib.h b/include/X11/Xlib.h
index f62fb470..29ea5715 100644
--- a/include/X11/Xlib.h
+++ b/include/X11/Xlib.h
@@ -1735,6 +1735,10 @@ extern Status XInitThreads(
void
);
+extern Status XFreeThreads(
+ void
+);
+
extern void XLockDisplay(
Display* /* display */
);
diff --git a/man/XInitThreads.man b/man/XInitThreads.man
index 4ae95228..b629bd28 100644
--- a/man/XInitThreads.man
+++ b/man/XInitThreads.man
@@ -52,6 +52,8 @@ XInitThreads, XLockDisplay, XUnlockDisplay \- multi-threading support
.HP
Status XInitThreads\^(void);
.HP
+Status XFreeThreads\^(void);
+.HP
void XLockDisplay\^(\^Display *\fIdisplay\fP\^);
.HP
void XUnlockDisplay\^(\^Display *\fIdisplay\fP\^);
@@ -76,7 +78,11 @@ are protected by some other access mechanism (for example,
a mutual exclusion lock in a toolkit or through explicit client
programming), Xlib thread initialization is not required.
It is recommended that single-threaded programs not call this function.
-
+.LP
+The
+.B XFreeThreads
+function frees the memory allocated by
+.BR XInitThreads .
.LP
The
.B XLockDisplay
diff --git a/src/globals.c b/src/globals.c
index 66b589fe..c07de431 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -105,4 +105,10 @@ xlib_ctor(void)
{
XInitThreads();
}
+
+__attribute__((destructor)) static void
+xlib_dtor(void)
+{
+ XFreeThreads();
+}
#endif
diff --git a/src/locking.c b/src/locking.c
index 36530691..bdc07011 100644
--- a/src/locking.c
+++ b/src/locking.c
@@ -673,9 +673,32 @@ Status XInitThreads(void)
return 1;
}
+Status XFreeThreads(void)
+{
+ if (global_lock.lock != NULL) {
+ xmutex_free(global_lock.lock);
+ global_lock.lock = NULL;
+ }
+ if (i18n_lock.lock != NULL) {
+ xmutex_free(i18n_lock.lock);
+ i18n_lock.lock = NULL;
+ }
+ if (conv_lock.lock != NULL) {
+ xmutex_free(conv_lock.lock);
+ conv_lock.lock = NULL;
+ }
+
+ return 1;
+}
+
#else /* XTHREADS */
Status XInitThreads(void)
{
return 0;
}
+
+Status XFreeThreads(void)
+{
+ return 0;
+}
#endif /* XTHREADS */
--
2.35.3