From b5c98aa6779b97882246b03c5dea646bd1355991 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 23 Feb 2017 10:21:49 +1000 Subject: [PATCH] os: log a bug whenever WriteToClient is called from the input thread The input thread should generate events, not send them. Make it easier to find the instances where it's doing so. Signed-off-by: Peter Hutterer Tested-by: Olivier Fourdan Reviewed-by: Olivier Fourdan (cherry picked from commit 1b12249fd6d4d3b566043d556503f3f625b9b4ba) --- include/input.h | 1 + os/inputthread.c | 8 ++++++++ os/io.c | 3 +++ 3 files changed, 12 insertions(+) diff --git a/include/input.h b/include/input.h index bb58b2200..6c9e45df6 100644 --- a/include/input.h +++ b/include/input.h @@ -722,6 +722,7 @@ extern _X_HIDDEN void input_constrain_cursor(DeviceIntPtr pDev, ScreenPtr screen extern _X_EXPORT void input_lock(void); extern _X_EXPORT void input_unlock(void); extern _X_EXPORT void input_force_unlock(void); +extern _X_EXPORT int in_input_thread(void); extern void InputThreadPreInit(void); extern void InputThreadInit(void); diff --git a/os/inputthread.c b/os/inputthread.c index 8e7f2edb9..721e86312 100644 --- a/os/inputthread.c +++ b/os/inputthread.c @@ -90,6 +90,13 @@ static pthread_mutex_t input_mutex; static Bool input_mutex_initialized; #endif +int +in_input_thread(void) +{ + return inputThreadInfo && + pthread_equal(pthread_self(), inputThreadInfo->thread); +} + void input_lock(void) { @@ -529,6 +536,7 @@ void input_force_unlock(void) {} void InputThreadPreInit(void) {} void InputThreadInit(void) {} void InputThreadFini(void) {} +int in_input_thread(void) { return 0; } int InputThreadRegisterDev(int fd, NotifyFdProcPtr readInputProc, diff --git a/os/io.c b/os/io.c index 5ba1e86b1..234c0f33f 100644 --- a/os/io.c +++ b/os/io.c @@ -652,6 +652,9 @@ WriteToClient(ClientPtr who, int count, const void *__buf) int padBytes; const char *buf = __buf; + BUG_RETURN_VAL_MSG(in_input_thread(), 0, + "******** %s called from input thread *********\n", __func__); + #ifdef DEBUG_COMMUNICATION Bool multicount = FALSE; #endif