_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor)
{
_EGLDriver *drv = NULL;
+ EGLBoolean ok;
int i;
_eglLockMutex(_eglGlobal.Mutex);
if (_eglGlobal.NumDrivers == 0)
continue;
drv = _eglGlobal.Drivers[0];
- if (drv->API.Initialize(drv, dpy, major, minor))
- break;
+
+ _eglUnlockMutex(_eglGlobal.Mutex);
+ ok = drv->API.Initialize(drv, dpy, major, minor);
+ _eglLockMutex(_eglGlobal.Mutex);
+ if (ok)
+ break;
+
_eglUnloadDrivers();
- }
+ }
_eglUnlockMutex(_eglGlobal.Mutex);