Merge branch '7.40'

This commit is contained in:
John Cupitt 2014-09-19 11:49:30 +01:00
commit f18fd4b089
2 changed files with 27 additions and 19 deletions

View File

@ -20,6 +20,7 @@
- vipsthumbnail retries with specified input profile if embedded profile is - vipsthumbnail retries with specified input profile if embedded profile is
broken broken
- add @profile option to pngsave, matching tiff and jpeg - add @profile option to pngsave, matching tiff and jpeg
- fix a race in the operation cache [Lovell]
8/9/14 started 7.40.8 8/9/14 started 7.40.8
- fix configure on rhel6 [Lovell] - fix configure on rhel6 [Lovell]

View File

@ -601,10 +601,7 @@ vips_cache_insert( VipsOperation *operation )
{ {
VipsOperationCacheEntry *entry = g_new( VipsOperationCacheEntry, 1 ); VipsOperationCacheEntry *entry = g_new( VipsOperationCacheEntry, 1 );
/* It must not be in cache. entry = g_new( VipsOperationCacheEntry, 1 );
*/
g_assert( !g_hash_table_lookup( vips_cache_table, operation ) );
entry->operation = operation; entry->operation = operation;
entry->time = 0; entry->time = 0;
entry->invalidate_id = 0; entry->invalidate_id = 0;
@ -759,28 +756,38 @@ vips_cache_operation_buildp( VipsOperation **operation )
*operation = hit->operation; *operation = hit->operation;
} }
/* We have to unlock between search and add so that more than one
* _build() can run at once.
*/
g_mutex_unlock( vips_cache_lock ); g_mutex_unlock( vips_cache_lock );
if( !hit ) { if( !hit ) {
if( vips_object_build( VIPS_OBJECT( *operation ) ) ) if( vips_object_build( VIPS_OBJECT( *operation ) ) )
return( -1 ); return( -1 );
/* Has to be after _build() so we can see output args.
*/
if( vips__cache_trace ) {
if( vips_operation_get_flags( *operation ) &
VIPS_OPERATION_NOCACHE )
printf( "vips cache : " );
else
printf( "vips cache+: " );
vips_object_print_summary( VIPS_OBJECT( *operation ) );
}
g_mutex_lock( vips_cache_lock ); g_mutex_lock( vips_cache_lock );
if( !(vips_operation_get_flags( *operation ) & /* If two threads call the same operation at the same time,
VIPS_OPERATION_NOCACHE) ) * we can get multiple adds. Let the first one win. See
vips_cache_insert( *operation ); * https://github.com/jcupitt/libvips/pull/181
*/
if( !g_hash_table_lookup( vips_cache_table, operation ) ) {
/* Has to be after _build() so we can see output args.
*/
if( vips__cache_trace ) {
if( vips_operation_get_flags( *operation ) &
VIPS_OPERATION_NOCACHE )
printf( "vips cache : " );
else
printf( "vips cache+: " );
vips_object_print_summary(
VIPS_OBJECT( *operation ) );
}
if( !(vips_operation_get_flags( *operation ) &
VIPS_OPERATION_NOCACHE) )
vips_cache_insert( *operation );
}
g_mutex_unlock( vips_cache_lock ); g_mutex_unlock( vips_cache_lock );
} }