[PATCH 2/2] mi: Log an error if mieqProcessInputEvents() recurses.

Jeremy Huddleston jeremyhu at apple.com
Fri Jun 15 00:55:19 PDT 2012


Can you please put the XQuartz mutex lock inside of the inProcessInputEvents grab/release.  I know the number of instructions is small, but there's no reason to hold the lock when checking or setting inProcessInputEvents.  It's a mutex on miEventQueue.

Thanks,
Jeremy

On Jun 14, 2012, at 9:15 AM, Andy Ritger <aritger at nvidia.com> wrote:

> Also, remove the unnecessary static qualifier on mieqProcessInputEvents()'s
> 'event' local variable.
> 
> Signed-off-by: Andy Ritger <aritger at nvidia.com>
> ---
> mi/mieq.c |   16 +++++++++++++++-
> 1 files changed, 15 insertions(+), 1 deletions(-)
> 
> diff --git a/mi/mieq.c b/mi/mieq.c
> index e117a8d..8339afb 100644
> --- a/mi/mieq.c
> +++ b/mi/mieq.c
> @@ -569,14 +569,25 @@ mieqProcessInputEvents(void)
> {
>     EventRec *e = NULL;
>     ScreenPtr screen;
> -    static InternalEvent event;
> +    InternalEvent event;
>     DeviceIntPtr dev = NULL, master = NULL;
>     size_t n_enqueued;
> +    static Bool inProcessInputEvents = FALSE;
> 
> #ifdef XQUARTZ
>     pthread_mutex_lock(&miEventQueueMutex);
> #endif
> 
> +    /*
> +     * report an error if mieqProcessInputEvents() is called recursively;
> +     * this can happen, e.g., if something in the mieqProcessDeviceEvent()
> +     * call chain calls UpdateCurrentTime() instead of UpdateCurrentTimeIf()
> +     */
> +    if (inProcessInputEvents) {
> +        ErrorF("[mi] mieqProcessInputEvents() called recursively.\n");
> +    }
> +    inProcessInputEvents = TRUE;
> +
>     /* Grow our queue if we are reaching capacity: < 2 * QUEUE_RESERVED_SIZE remaining */
>     n_enqueued = mieqNumEnqueued(&miEventQueue);
>     if (n_enqueued >= (miEventQueue.nevents - (2 * QUEUE_RESERVED_SIZE)) &&
> @@ -631,6 +642,9 @@ mieqProcessInputEvents(void)
>         pthread_mutex_lock(&miEventQueueMutex);
> #endif
>     }
> +
> +    inProcessInputEvents = FALSE;
> +
> #ifdef XQUARTZ
>     pthread_mutex_unlock(&miEventQueueMutex);
> #endif
> -- 
> 1.7.7
> 
> _______________________________________________
> 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