Always call dlopen in DriverOpen.
authorGeorge Nassas <gnassas@gmail.com>
Thu, 6 Dec 2007 09:11:05 +0000 (10:11 +0100)
committerMichel Dänzer <michel@tungstengraphics.com>
Thu, 6 Dec 2007 09:11:05 +0000 (10:11 +0100)
This increases the reference count for the driver binary, preventing it from
getting unloaded prematurely in driDestroyDisplay. See
https://bugs.freedesktop.org/show_bug.cgi?id=13541 .

src/glx/x11/dri_glx.c
src/glx/x11/glxclient.h

index c02f105611c9f620abea19f821674ccc39a36e2c..9c3a78b31b7153009a205bdaebd907497b195601 100644 (file)
@@ -194,7 +194,8 @@ static __DRIdriver *OpenDriver(const char *driverName)
    /* First, search Drivers list to see if we've already opened this driver */
    for (driver = Drivers; driver; driver = driver->next) {
       if (strcmp(driver->name, driverName) == 0) {
-         /* found it */
+         /* found it, increment library refcount & return */
+         dlopen(driver->libpath, RTLD_NOW | RTLD_GLOBAL);
          return driver;
       }
    }
@@ -238,7 +239,9 @@ static __DRIdriver *OpenDriver(const char *driverName)
             break; /* out of memory! */
          /* init the struct */
          driver->name = __glXstrdup(driverName);
-         if (!driver->name) {
+         driver->libpath = __glXstrdup(realDriverName);
+         if (!driver->name || !driver->libpath) {
+            if (driver->name) XFree(driver->name);
             Xfree(driver);
             driver = NULL;
             break; /* out of memory! */
@@ -401,6 +404,7 @@ static void driDestroyDisplay(Display *dpy, void *private)
                       Drivers = driver->next;
 
                    Xfree(driver->name);
+                   Xfree(driver->libpath);
                    Xfree(driver);
                    break;
                 }
index 05354073c45d089f4db537569955f6208b9c4e72..7054f3cc310efe754b713f4c621bc31c4be04081 100644 (file)
@@ -117,6 +117,7 @@ struct __DRIdisplayRec {
 */
 struct __DRIdriverRec {
    const char *name;
+   const char *libpath;
    void *handle;
    PFNCREATENEWSCREENFUNC createNewScreenFunc;
    struct __DRIdriverRec *next;