[PATCH libX11] Always initialise thread support
Daniel Stone
daniel at fooishbar.org
Sun Jul 14 09:31:38 PDT 2013
Hi,
On 14 July 2013 17:17, Mark Kettenis <mark.kettenis at xs4all.nl> wrote:
>> Make XOpenDisplay always call XInitThreads when opening a display, thus
>> guarding it against possible disaster scenarios like calling
>> XOpenDisplay without XInitThreads, then passing the Display pointer into
>> an EGL library which uses threads. Or any of the other five similar
>> failure scenarios I've seen just this week.
>
> Isn't the real solution to these problems to change the EGL library to
> use xcb?
As the last sentence alludes to, it's not just this one EGL stack, or
EGL in general. It's pretty hard to construct a program more complex
than xterm whilst totally avoiding threads.
> Forcing the overhead of per-request locking down everybodies throat
> isn't very nice, even if the overhead is relatively small.
Beats the overhead of having to figure out what's wrong and add
XInitThreads() to random apps which don't use threads themselves, but
have threads forced on them by any number of support libraries, most
of which can't call XInitThreads() in time before someone else calls
XOpenDisplay().
An XUnInitThreads() for programs which could 100% guarantee no threads
will ever be used might be more interesting. Or just have those
performance-critical programs use XCB, since Xlib sucks for
performance anyway.
Cheers,
Daniel
>> Signed-off-by: Daniel Stone <daniel at fooishbar.org>
>> ---
>> src/OpenDis.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/src/OpenDis.c b/src/OpenDis.c
>> index fc67d1a..2104845 100644
>> --- a/src/OpenDis.c
>> +++ b/src/OpenDis.c
>> @@ -87,6 +87,8 @@ XOpenDisplay (
>> long int conn_buf_size;
>> char *xlib_buffer_size;
>>
>> + XInitThreads();
>> +
>> /*
>> * If the display specifier string supplied as an argument to this
>> * routine is NULL or a pointer to NULL, read the DISPLAY variable.
>> --
>> 1.8.3.1
>>
>> _______________________________________________
>> xorg-devel at lists.x.org: X.Org development
>> Archives: http://lists.x.org/archives/xorg-devel
>> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>>
More information about the xorg-devel
mailing list