summaryrefslogtreecommitdiffstats
path: root/src/egl/main/egldriver.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-02-17 19:03:30 +0800
committerChia-I Wu <[email protected]>2010-02-17 20:00:12 +0800
commit4afe24808ee253c44c65b855f65bd0749c1e1524 (patch)
treee7ec43369a44966988dac08c9356b4a2b4e9c76f /src/egl/main/egldriver.c
parent655f4654675e601a9482e40d8e50156c965b8934 (diff)
egl: Revisit global data locking.
Lock the global mutex in _eglPreloadDrivers and _eglAllocScreenHandle. Add comments to why certain pathes do not need locking.
Diffstat (limited to 'src/egl/main/egldriver.c')
-rw-r--r--src/egl/main/egldriver.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index a87c697b113..8748fe5f467 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -237,6 +237,10 @@ _eglMatchDriver(_EGLDisplay *dpy)
_EGLDriver *best_drv = NULL;
EGLint best_score = -1, i;
+ /*
+ * this function is called after preloading and the drivers never change
+ * after preloading.
+ */
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
_EGLDriver *drv = _eglGlobal.Drivers[i];
EGLint score;
@@ -529,14 +533,21 @@ _eglPreloadDrivers(void)
{
EGLBoolean loaded;
+ /* protect the preloading process */
+ _eglLockMutex(_eglGlobal.Mutex);
+
/* already preloaded */
- if (_eglGlobal.NumDrivers)
+ if (_eglGlobal.NumDrivers) {
+ _eglUnlockMutex(_eglGlobal.Mutex);
return EGL_TRUE;
+ }
loaded = (_eglPreloadUserDriver() ||
_eglPreloadDisplayDrivers() ||
_eglPreloadDefaultDriver());
+ _eglUnlockMutex(_eglGlobal.Mutex);
+
return loaded;
}
@@ -548,6 +559,8 @@ void
_eglUnloadDrivers(void)
{
EGLint i;
+
+ /* this is called at atexit time */
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
_EGLDriver *drv = _eglGlobal.Drivers[i];
lib_handle handle = drv->LibHandle;