From 8738ce85df535bdfdfecfce1c0d64e209cc6e508 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 16 Nov 2018 14:36:55 -0500 Subject: [PATCH] dix: ensure work queues are cleared on reset If the server resets, most client workqueues are cleaned up as the clients are killed. The one exception is the server's client, which is exempt from the killing spree. If that client has a queued work procedure active, it won't get cleared on reset. This commit ensures it gets cleared too. --- dix/dixutils.c | 13 +++++++++++++ dix/main.c | 2 ++ include/dix.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/dix/dixutils.c b/dix/dixutils.c index 540023cbdf..2983174a17 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -507,6 +507,19 @@ InitBlockAndWakeupHandlers(void) WorkQueuePtr workQueue; static WorkQueuePtr *workQueueLast = &workQueue; +void +ClearWorkQueue(void) +{ + WorkQueuePtr q, *p; + + p = &workQueue; + while ((q = *p)) { + *p = q->next; + free(q); + } + workQueueLast = p; +} + void ProcessWorkQueue(void) { diff --git a/dix/main.c b/dix/main.c index 273f303300..16a7d6d390 100644 --- a/dix/main.c +++ b/dix/main.c @@ -340,6 +340,8 @@ dix_main(int argc, char *argv[], char *envp[]) DeleteCallbackManager(); + ClearWorkQueue(); + if (dispatchException & DE_TERMINATE) { CloseWellKnownConnections(); } diff --git a/include/dix.h b/include/dix.h index cf263a1f52..f2516187f9 100644 --- a/include/dix.h +++ b/include/dix.h @@ -240,6 +240,8 @@ extern _X_EXPORT void RemoveBlockAndWakeupHandlers(ServerBlockHandlerProcPtr blo extern _X_EXPORT void InitBlockAndWakeupHandlers(void); +extern _X_EXPORT void ClearWorkQueue(void); + extern _X_EXPORT void ProcessWorkQueue(void); extern _X_EXPORT void ProcessWorkQueueZombies(void);