From af9f70013abc4201c473da7485addc898da4d0da Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 19 Feb 2024 12:52:25 +0100 Subject: [PATCH] dix: dixutils: make workQueue pointer dix-private The workQueue pointer is currently declared extern, so that WaitForSomething() can check wether we've got something in the queue and call ProcessWorkQueue() then. But that's trivial to simplify: just let ProcessWorkQueue() return early if workQueue == NULL. Gives us a better isolation of internal stuff as well as ProcessWorkQueue() protecting itself from possible segfault. Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- dix/dixutils.c | 4 ++++ doc/Xserver-spec.xml | 9 +++------ os/WaitFor.c | 4 +--- os/osdep.h | 2 -- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dix/dixutils.c b/dix/dixutils.c index 331ccfb96..a11c82e9f 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -525,6 +525,10 @@ ProcessWorkQueue(void) { WorkQueuePtr q, *p; + // don't have a work queue yet + if (!workQueue) + return; + p = &workQueue; /* * Scan the work queue once, calling each function. Those diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml index 15ecb0fd5..f33d90475 100644 --- a/doc/Xserver-spec.xml +++ b/doc/Xserver-spec.xml @@ -657,14 +657,11 @@ make the server suspend until one or more of the following occurs: Before WaitForSomething() computes the masks to pass to select, poll or similar operating system interface, it needs to -see if there is anything to do on the work queue; if so, it must call a DIX -routine called ProcessWorkQueue. +see if there is anything to do on the work queue; it must call a DIX +routine called ProcessWorkQueue().
- extern WorkQueuePtr workQueue; - - if (workQueue) - ProcessWorkQueue (); + ProcessWorkQueue ();
diff --git a/os/WaitFor.c b/os/WaitFor.c index ff1d376e9..1bb4ecc45 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -188,9 +188,7 @@ WaitForSomething(Bool are_ready) crashed connections and the screen saver timeout */ while (1) { /* deal with any blocked jobs */ - if (workQueue) { - ProcessWorkQueue(); - } + ProcessWorkQueue(); timeout = check_timers(); are_ready = clients_are_ready(); diff --git a/os/osdep.h b/os/osdep.h index 5b64f1a38..85fc7f9a1 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -123,8 +123,6 @@ listen_to_client(ClientPtr client); extern Bool NewOutputPending; -extern WorkQueuePtr workQueue; - /* in access.c */ extern Bool ComputeLocalClient(ClientPtr client);