summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-03-27 08:58:59 -0600
committerBrian Paul <brianp@vmware.com>2010-03-27 08:58:59 -0600
commit038d2607ab759638217ded3bd1b232d389975af5 (patch)
tree46492ca40b991dde7dda7c87095b27c5d41b710b /src
parent7996f0fc2c167c84552701be7a48d20a897e7978 (diff)
downloadexternal_mesa3d-038d2607ab759638217ded3bd1b232d389975af5.zip
external_mesa3d-038d2607ab759638217ded3bd1b232d389975af5.tar.gz
external_mesa3d-038d2607ab759638217ded3bd1b232d389975af5.tar.bz2
mesa: fix deadlock in _mesa_HashFindFreeKeyBlock()
Fixes fd.o bug 27340. (cherry picked from commit 8fe3b3f66ae57a1a6eca7f6dcb0455e14ad92075)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/hash.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index 9757754..f4af3fd 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -127,8 +127,8 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table)
*
* \return pointer to user's data or NULL if key not in table
*/
-void *
-_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key)
+static INLINE void *
+_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key)
{
GLuint pos;
const struct HashEntry *entry;
@@ -137,19 +137,26 @@ _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key)
assert(key);
pos = HASH_FUNC(key);
- _glthread_LOCK_MUTEX(table->Mutex);
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {
- _glthread_UNLOCK_MUTEX(table->Mutex);
return entry->Data;
}
entry = entry->Next;
}
- _glthread_UNLOCK_MUTEX(table->Mutex);
return NULL;
}
+void *
+_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key)
+{
+ void *res;
+ assert(table);
+ _glthread_LOCK_MUTEX(table->Mutex);
+ res = _mesa_HashLookup_unlocked(table, key);
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return res;
+}
/**
@@ -447,7 +454,7 @@ _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys)
GLuint freeStart = 1;
GLuint key;
for (key = 1; key != maxKey; key++) {
- if (_mesa_HashLookup(table, key)) {
+ if (_mesa_HashLookup_unlocked(table, key)) {
/* darn, this key is already in use */
freeCount = 0;
freeStart = key+1;