Prevent non-critical race condition in op cache

First thread to add an operation 'wins'
This commit is contained in:
Lovell Fuller 2014-09-19 09:18:58 +01:00
parent 14a8c5ad47
commit 20ae6b8af7

View File

@ -599,12 +599,12 @@ vips_cache_ref( VipsOperation *operation )
static void
vips_cache_insert( VipsOperation *operation )
{
VipsOperationCacheEntry *entry = g_new( VipsOperationCacheEntry, 1 );
/* It must not be in cache.
*/
g_assert( !g_hash_table_lookup( vips_cache_table, operation ) );
if( g_hash_table_lookup( vips_cache_table, operation ) )
return;
VipsOperationCacheEntry *entry = g_new( VipsOperationCacheEntry, 1 );
entry->operation = operation;
entry->time = 0;
entry->invalidate_id = 0;