On Tue, 2012-01-10 at 19:46 -0700, Brian Paul wrote:
> From: Brian Paul <bri...@vmware.com>
> 
> This is a follow-on to the previous commits.  It seems that
> XShmQueryVersion() can trigger an X error after the first X
> connection is closed and we start using a new connection.

I assume this is when you switch which Display you're talking to as
well.

> +static int
> +xshm_query_version_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr )
> +{
> +   /* If this function gets called, it's because XShmQuerryVersion()
> +    * has failed.
> +    */
> +   XShmErrorFlag = True;
> +   return 0;
> +}

Not safe against a process using multiple Display connections, which is
admittedly quite rare.  There's a few instances of that kind of bug
already though, I wouldn't call it a blocker.

> +      /* Install X error handler before calling XShmQueryVersion() to catch
> +       * a spurious X error.
> +       */
> +      XShmErrorFlag = False;
> +      old_handler = XSetErrorHandler(xshm_query_version_err_handler);
> +      ok = XShmQueryVersion( display, &major, &minor, &pixmaps );
> +      XSetErrorHandler(old_handler);
> +      if (XShmErrorFlag)
> +         ok = False;
> +
> +      if (ok) {

Not thread-safe, though it's tough to hit.  You want an XLockDisplay
before the first XSetErrorHandler and the matching XUnlockDisplay after
the second, otherwise your handler can get called for errors on other
threads.

- ajax

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to