more tiny buffer fixups

This commit is contained in:
John Cupitt 2016-10-12 12:46:27 +01:00
parent 463d2e885f
commit cf98b92dbf
2 changed files with 7 additions and 16 deletions

13
TODO
View File

@ -1,18 +1,5 @@
- try valgrind sharp again on desktop
- add some stuff to count main thread buffers being created and destroyed,
verify that we are now handling that
- vips_sink_disc() calls wbuffer_position() which will set up the first
buffer ... but that's called from the main thread and so will create a
global buffer
can we call this from a worker instead and save a few locks?
- vips_region_dispose() calls vips_buffer_unref() which calls
buffer_cache_get(), which will create a main-thread buffercache ... can we
fix this?
- do we need all the locks?
- benchmark again and confirm we've not slowed down

View File

@ -477,8 +477,11 @@ vips_buffer_unref( VipsBuffer *buffer )
buffer->ref_count -= 1;
if( buffer->ref_count == 0 ) {
VipsImage *im = buffer->im;
VipsBufferCache *cache = buffer_cache_get( im );
/* We are not always the creating thread, for example if we
* come here during vips_region_dispose(). cache may have been
* NULLed out during thread exit.
*/
VipsBufferCache *cache = buffer->cache;
#ifdef DEBUG_VERBOSE
if( !buffer->done )
@ -489,7 +492,8 @@ vips_buffer_unref( VipsBuffer *buffer )
/* Place on this thread's reserve list for reuse.
*/
if( cache->n_reserve < buffer_cache_max_reserve ) {
if( cache &&
cache->n_reserve < buffer_cache_max_reserve ) {
g_assert( !buffer->cache );
cache->reserve =