diff options
author | Keith Packard <keithp@keithp.com> | 2015-12-08 11:37:51 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-05-26 16:07:54 -0700 |
commit | 30ac7567980a1eb79d084a63e0e74e1d9a3af673 (patch) | |
tree | 6864c1ea181723bf9bde36638193ca65e0f8929d /dix | |
parent | 728c9570a05f03bd90343ff6f5b1a8fd3988864c (diff) |
Create a threaded mechanism for input [v7]
The current SIGIO signal handler method, used at generation of input events,
has a bunch of oddities. This patch introduces an alternative way using a
thread, which is used to select() all input device file descriptors.
A mutex was used to control the access to input structures by the main and input
threads. Two pipes to emit alert events (such hotplug ones) and guarantee the
proper communication between them was also used.
Co-authored-by: Fernando Carrijo <fcarrijo@freedesktop.org>
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
v2: Fix non-Xorg link. Enable where supported by default.
This also splits out the actual enabling of input threads to
DDX-specific patches which follow
v3: Make the input lock recursive
v4: Use regular RECURSIVE_MUTEXes instead of rolling our own
Respect the --disable-input-thread configuration option by
providing stubs that expose the same API/ABI.
Respond to style comments from Peter Hutterer.
v5: use __func__ in inputthread debug and error mesages.
Respond to style comments from Peter Hutterer.
v6: use AX_PTHREAD instead of inlining pthread tests.
Suggested by Emil Velikov <emil.l.velikov@gmail.com>
v7: Use pthread_sigmask instead of sigprocmask when using threads
Suggested by Adam Jackson <ajax@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/globals.c | 9 | ||||
-rw-r--r-- | dix/main.c | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/dix/globals.c b/dix/globals.c index f36a938f7..e3139303f 100644 --- a/dix/globals.c +++ b/dix/globals.c @@ -132,3 +132,12 @@ Bool explicit_display = FALSE; char *ConnectionInfo; CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND; + +#if DEBUG_INPUT_MUTEX +#define INPUT_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +#else +#define INPUT_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#endif + +pthread_mutex_t input_mutex = INPUT_MUTEX_INITIALIZER; +__thread int input_mutex_count; diff --git a/dix/main.c b/dix/main.c index 77e0f2ecb..4ba43133e 100644 --- a/dix/main.c +++ b/dix/main.c @@ -121,12 +121,9 @@ Equipment Corporation. extern void Dispatch(void); #ifdef XQUARTZ -#include <pthread.h> - -BOOL serverRunning = FALSE; +BOOL serverRunning; pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER; - #endif CallbackListPtr RootWindowFinalizeCallback = NULL; @@ -299,6 +296,8 @@ dix_main(int argc, char *argv[], char *envp[]) NotifyParentProcess(); + InputThreadInit(); + Dispatch(); #ifdef XQUARTZ @@ -331,6 +330,8 @@ dix_main(int argc, char *argv[], char *envp[]) CloseInput(); + InputThreadFini(); + for (i = 0; i < screenInfo.numScreens; i++) screenInfo.screens[i]->root = NullWindow; |