Now that we use recursive locking for the hash table mutex, it is possible to pass a callback to that remove the entry to _mesa_HashDeleteAll() without getting stuck waiting for a lock. However we will end up removing the entry twice and the hash table entry counts will get messed up.
To avoid messing up the entry counts we check to see if the entry is already deleted before calling remove in _mesa_HashDeleteAll(). --- src/mesa/main/hash.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 670438a..e7f3333 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -389,7 +389,12 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, table->InDeleteAll = GL_TRUE; hash_table_foreach(table->ht, entry) { callback((uintptr_t)entry->key, entry->data, userData); - _mesa_hash_table_remove(table->ht, entry); + /* Check that the cb didn't already remove the entry. If not + * remove it. + */ + if (entry->key != table->ht->deleted_key) { + _mesa_hash_table_remove(table->ht, entry); + } } if (table->deleted_key_data) { callback(DELETED_KEY_VALUE, table->deleted_key_data, userData); -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev