improve compat with ancient glibs

and fix a tiny threading leak
This commit is contained in:
John Cupitt 2016-10-28 16:25:31 +01:00
parent b12d5f8205
commit a7edd235c4
5 changed files with 31 additions and 7 deletions

View File

@ -1,5 +1,7 @@
18/10/16 started 8.4.3
- fix error detection in gif_close, thanks aaron42net
- fix tiny threading memleak
- improve compatibility with very old glib, see #548
27/9/16 started 8.4.2
- small doc improvements

View File

@ -102,6 +102,8 @@ extern char *vips__cache_max_files;
extern gboolean vips__cache_dump;
extern gboolean vips__cache_trace;
void vips__threadpool_init( void );
void vips__cache_init( void );
void vips__print_renders( void );

View File

@ -712,7 +712,7 @@ buffer_thread_destroy_notify( VipsBufferThread *buffer_thread )
buffer_thread_free( buffer_thread );
}
/* Init the buffer cache system.
/* Init the buffer cache system. This is called during vips_init.
*/
void
vips__buffer_init( void )

View File

@ -302,6 +302,9 @@ vips_init( const char *argv0 )
g_thread_init( NULL );
#endif
vips__threadpool_init();
vips__buffer_init();
/* This does an unsynchronised static hash table init on first call --
* we have to make sure we do this single-threaded. See:
* https://github.com/openslide/openslide/issues/161

View File

@ -101,7 +101,7 @@ int vips__concurrency = 0;
/* Set this GPrivate to indicate that this is a vips worker.
*/
static GPrivate vips_threadpool_is_worker_private;
static GPrivate *is_worker_key = NULL;
/* Glib 2.32 revised the thread API. We need some compat functions.
*/
@ -165,7 +165,7 @@ vips_g_cond_free( GCond *cond )
gboolean
vips_thread_isworker( void )
{
return( g_private_get( &vips_threadpool_is_worker_private ) != NULL );
return( g_private_get( is_worker_key ) != NULL );
}
typedef struct {
@ -181,12 +181,12 @@ vips_thread_run( gpointer data )
void *result;
if( vips__thread_profile )
vips__thread_profile_attach( info->domain );
/* Set this to something (anything) to tag this thread as a vips worker.
*/
g_private_set( &vips_threadpool_is_worker_private, data );
g_private_set( is_worker_key, data );
if( vips__thread_profile )
vips__thread_profile_attach( info->domain );
result = info->func( info->data );
@ -940,6 +940,23 @@ vips_threadpool_run( VipsImage *im,
return( result );
}
/* Start up threadpools. This is called during vips_init.
*/
void
vips__threadpool_init( void )
{
/* We need to work with the pre-2.32 threading API.
*/
#ifdef HAVE_PRIVATE_INIT
static GPrivate private = { 0 };
is_worker_key = &private;
#else
if( !is_worker_key )
is_worker_key = g_private_new( NULL );
#endif
}
/**
* vips_get_tile_size:
* @im: image to guess for