From c8d81691603b08fd5dbe14c6085f8391003917de Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 11 Apr 2022 12:40:31 +0100 Subject: [PATCH 1/6] add "configure" operation This operation can be used to set various library config options, such as vips_block_untrusted_set(). Having these options available as an operation makes like simpler for bindings: they can expose them all via the usual introspection system. Example: ```python pyvips.Image.configure(untrusted_block=True) ``` --- .gitignore | 1 + ChangeLog | 3 +- libvips/iofuncs/Makefile.am | 1 + libvips/iofuncs/configure.c | 177 ++++++++++++++++++++++++++++++++++++ libvips/iofuncs/init.c | 2 + libvips/iofuncs/meson.build | 1 + libvips/iofuncs/operation.c | 5 +- 7 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 libvips/iofuncs/configure.c diff --git a/.gitignore b/.gitignore index 55c8283bdf..e986f7faf8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ compile +build .pytest_cache .dirstamp a.out diff --git a/ChangeLog b/ChangeLog index a6bed66826..fed1ad14dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,6 @@ 21/11/21 started 8.13 - configure fails for requested but unmet dependencies [remicollet] - add support for another quantiser [DarthSim] -- add "extend", "background" and "premultiplied" to mapim to fix edge - antialiasing [GavinJoyce] - add support for HDR HEIC and AVIF images - add spngsave - jpeg2000 load left-justifies bitdepth @@ -17,6 +15,7 @@ - add maxerror to gifsave [dloebl] - update libnsgif API [tlsa] - deprecate "properties" option to dzsave (now always on) +- add vips_configure() ... set various config options 26/11/21 started 8.12.3 - better arg checking for hist_find_ndim [travisbell] diff --git a/libvips/iofuncs/Makefile.am b/libvips/iofuncs/Makefile.am index ec5988450f..2130fd9a89 100644 --- a/libvips/iofuncs/Makefile.am +++ b/libvips/iofuncs/Makefile.am @@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libiofuncs.la libiofuncs_la_SOURCES = \ ginputsource.c \ sourceginput.c \ + configure.c \ connection.c \ source.c \ sourcecustom.c \ diff --git a/libvips/iofuncs/configure.c b/libvips/iofuncs/configure.c new file mode 100644 index 0000000000..18fce280c8 --- /dev/null +++ b/libvips/iofuncs/configure.c @@ -0,0 +1,177 @@ +/* vips_configure(): set/clear various libvips settings + * + * 11/04/22 + * - from configure.c + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif /*HAVE_UNISTD_H*/ +#include +#include +#include + +#include +#include + +typedef struct _VipsConfigure { + VipsOperation parent_instance; + + /* Block all untrusted operations. + */ + gboolean untrusted_block; + + /* Block a specific operation. + */ + char *operation_block; + + /* Unblock a specific operation. + */ + char *operation_unblock; + +} VipsConfigure; + +typedef VipsOperationClass VipsConfigureClass; + +G_DEFINE_TYPE( VipsConfigure, vips_configure, VIPS_TYPE_OPERATION ); + +static int +vips_configure_build( VipsObject *object ) +{ + VipsConfigure *configure = (VipsConfigure *) object; + + if( VIPS_OBJECT_CLASS( vips_configure_parent_class )->build( object ) ) + return( -1 ); + + if( vips_object_argument_isset( object, "untrusted_block" ) ) + vips_block_untrusted_set( configure->untrusted_block ); + + if( vips_object_argument_isset( object, "operation_block" ) ) + vips_operation_block_set( configure->operation_block, TRUE ); + if( vips_object_argument_isset( object, "operation_unblock" ) ) + vips_operation_block_set( configure->operation_block, FALSE ); + + return( 0 ); +} + +static void +vips_configure_class_init( VipsConfigureClass *class ) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS( class ); + VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class ); + VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class ); + + gobject_class->set_property = vips_object_set_property; + gobject_class->get_property = vips_object_get_property; + + vobject_class->nickname = "configure"; + vobject_class->description = _( "set various library options" ); + vobject_class->build = vips_configure_build; + + /* Commands can have side-effects, so don't cache them. + */ + operation_class->flags = VIPS_OPERATION_NOCACHE; + + VIPS_ARG_BOOL( class, "untrusted_block", 2, + _( "Block untrusted" ), + _( "Block all untrusted operations from running" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, untrusted_block ), + FALSE ); + + VIPS_ARG_STRING( class, "operation_block", 2, + _( "Block operation" ), + _( "Block an operation (and any subclasses) from running" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, operation_block ), + NULL ); + + VIPS_ARG_STRING( class, "operation_unblock", 2, + _( "Unblock operation" ), + _( "Unblock an operation (and any subclasses) from running" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, operation_unblock ), + NULL ); + +} + +static void +vips_configure_init( VipsConfigure *configure ) +{ +} + +/** + * vips_configure: + * @name: not used + * @...: %NULL-terminated list of optional named arguments + * + * Optional arguments: + * + * * @untrusted_block: %gboolean, Block all untrusted operations from running + * * @operation_block : %gchararray, Block an operation from running + * * @operation_unblock : %gchararray, Unblock an operation from running + * + * vips_configure() can be used to set a number of libvips configure + * options. + * + * If @untrusted_block is set, all libvips operations which have been tagged + * as unsafe for untrusted input will be blocked. All subclasses of these + * operations are also blocked. See vips_block_untrusted_set(). + * + * If @operation_block is set, the named libvips operation is blocked. All + * subclasses of this operation are also blocked. See + * vips_operation_block_set(). + * + * If @operation_unblock is set, the named libvips operation is unblocked. All + * subclasses of this operation are also unblocked. See + * vips_operation_block_set(). + * + * Returns: 0 on success, -1 on failure. + */ +int +vips_configure( const char *name, ... ) +{ + va_list ap; + int result; + + va_start( ap, name ); + result = vips_call_split( "configure", ap, name ); + va_end( ap ); + + return( result ); +} diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index dd560d0cb1..9ddeee7edf 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -434,6 +434,7 @@ int vips_init( const char *argv0 ) { extern GType vips_system_get_type( void ); + extern GType vips_configure_get_type( void ); extern GType write_thread_state_get_type( void ); extern GType sink_memory_thread_state_get_type( void ); extern GType render_thread_state_get_type( void ); @@ -578,6 +579,7 @@ vips_init( const char *argv0 ) /* Start up packages. */ (void) vips_system_get_type(); + (void) vips_configure_get_type(); vips_arithmetic_operation_init(); vips_conversion_operation_init(); vips_create_operation_init(); diff --git a/libvips/iofuncs/meson.build b/libvips/iofuncs/meson.build index eec82036bb..e103e1db43 100644 --- a/libvips/iofuncs/meson.build +++ b/libvips/iofuncs/meson.build @@ -1,6 +1,7 @@ iofuncs_sources = files( 'ginputsource.c', 'sourceginput.c', + 'configure.c', 'connection.c', 'source.c', 'sourcecustom.c', diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index 5043fc2260..44777fee19 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -33,6 +33,7 @@ /* #define VIPS_DEBUG +#define DEBUG */ #ifdef HAVE_CONFIG_H @@ -1432,9 +1433,9 @@ vips_operation_block_set_operation( VipsOperationClass *class, gboolean *state ) { g_assert( VIPS_IS_OPERATION_CLASS( class ) ); -#ifdef VIPS_DEBUG +#ifdef DEBUG if( ((class->flags & VIPS_OPERATION_BLOCKED) != 0) != *state ) - VIPS_DEBUG_MSG( "vips_operation_block_set_operation: " + printf( "vips_operation_block_set_operation: " "setting block state on %s = %d\n", VIPS_OBJECT_CLASS( class )->nickname, *state ); #endif From 2788ba53d23d977e5738a5894aa7fbbd2e6983fd Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 11 Apr 2022 17:17:12 +0100 Subject: [PATCH 2/6] make a note of configure settings Add a list of the settings that still need connecting. --- libvips/iofuncs/configure.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libvips/iofuncs/configure.c b/libvips/iofuncs/configure.c index 18fce280c8..fdc92c9067 100644 --- a/libvips/iofuncs/configure.c +++ b/libvips/iofuncs/configure.c @@ -64,6 +64,38 @@ typedef struct _VipsConfigure { */ char *operation_unblock; + /* Enable leak reporting. + */ + gboolean leak; + + /* Enable profiling + */ + gboolean profile; + + /* Threadpool size. + */ + int concurrency; + + /* Max size of pipe. + */ + int64 pipe_read_limit; + + /* Trace libvips operation cache actions. + */ + gboolean cache_trace; + + /* Number of recent operations to cache. + */ + int cache_max; + + /* Maximum memory to use for operation caching. + */ + int64 cache_max_mem; + + /* Maximum number of open files we allow in the cache. + */ + int cache_max_files; + } VipsConfigure; typedef VipsOperationClass VipsConfigureClass; From 096bba949dfb7076a34bb02f950e42be0cba66d6 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 12 Apr 2022 08:59:46 +0100 Subject: [PATCH 3/6] start adding some more configure options --- libvips/iofuncs/configure.c | 47 +++++++++++++++++++++++++++++++++++-- libvips/iofuncs/source.c | 1 - 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/libvips/iofuncs/configure.c b/libvips/iofuncs/configure.c index fdc92c9067..9597871e2a 100644 --- a/libvips/iofuncs/configure.c +++ b/libvips/iofuncs/configure.c @@ -146,25 +146,68 @@ vips_configure_class_init( VipsConfigureClass *class ) G_STRUCT_OFFSET( VipsConfigure, untrusted_block ), FALSE ); - VIPS_ARG_STRING( class, "operation_block", 2, + VIPS_ARG_STRING( class, "operation_block", 3, _( "Block operation" ), _( "Block an operation (and any subclasses) from running" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, operation_block ), NULL ); - VIPS_ARG_STRING( class, "operation_unblock", 2, + VIPS_ARG_STRING( class, "operation_unblock", 4, _( "Unblock operation" ), _( "Unblock an operation (and any subclasses) from running" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, operation_unblock ), NULL ); + VIPS_ARG_BOOL( class, "leak", 5, + _( "Leak" ), + _( "Report any leaks on exit" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, leak ), + FALSE ); + + VIPS_ARG_BOOL( class, "profile", 5, + _( "Profile" ), + _( "Write profiling data on exit" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, profile ), + FALSE ); + + VIPS_ARG_INT( class, "concurrency", 5, + _( "Concurrency" ), + _( "Set threadpool size" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, concurrency ), + -1 ); + + + /* Max size of pipe. + */ + int64 pipe_read_limit; + + /* Trace libvips operation cache actions. + */ + gboolean cache_trace; + + /* Number of recent operations to cache. + */ + int cache_max; + + /* Maximum memory to use for operation caching. + */ + int64 cache_max_mem; + + /* Maximum number of open files we allow in the cache. + */ + int cache_max_files; + } static void vips_configure_init( VipsConfigure *configure ) { + configure->concurrency = -1; } /** diff --git a/libvips/iofuncs/source.c b/libvips/iofuncs/source.c index d8d778e4de..4eb8249c90 100644 --- a/libvips/iofuncs/source.c +++ b/libvips/iofuncs/source.c @@ -1,4 +1,3 @@ -/* A byte source/sink .. it can be a pipe, file descriptor, memory area, * socket, node.js stream, etc. * * 19/6/14 From 13868abba7bde65d28c3ed9c373f3e66e5770132 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 12 Apr 2022 09:05:16 +0100 Subject: [PATCH 4/6] add gint64 args --- libvips/include/vips/object.h | 13 +++++++++++ libvips/iofuncs/configure.c | 43 +++++++++++++++++------------------ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 9b029a3850..757144dfdd 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -197,6 +197,19 @@ VIPS_ARGUMENT_OPTIONAL_OUTPUT Eg. the x pos of the image minimum pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \ } +#define VIPS_ARG_INT64( CLASS, NAME, PRIORITY, LONG, DESC, \ + FLAGS, OFFSET, MIN, MAX, VALUE ) { \ + GParamSpec *pspec; \ + \ + pspec = g_param_spec_int64( (NAME), (LONG), (DESC), \ + (MIN), (MAX), (VALUE), \ + (GParamFlags) (G_PARAM_READWRITE) );\ + g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \ + vips_argument_get_id(), pspec ); \ + vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \ + pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \ +} + #define VIPS_ARG_ENUM( CLASS, NAME, PRIORITY, LONG, DESC, \ FLAGS, OFFSET, TYPE, VALUE ) { \ GParamSpec *pspec; \ diff --git a/libvips/iofuncs/configure.c b/libvips/iofuncs/configure.c index 9597871e2a..053c018b68 100644 --- a/libvips/iofuncs/configure.c +++ b/libvips/iofuncs/configure.c @@ -78,7 +78,7 @@ typedef struct _VipsConfigure { /* Max size of pipe. */ - int64 pipe_read_limit; + gint64 pipe_read_limit; /* Trace libvips operation cache actions. */ @@ -90,7 +90,7 @@ typedef struct _VipsConfigure { /* Maximum memory to use for operation caching. */ - int64 cache_max_mem; + gint64 cache_max_mem; /* Maximum number of open files we allow in the cache. */ @@ -160,20 +160,6 @@ vips_configure_class_init( VipsConfigureClass *class ) G_STRUCT_OFFSET( VipsConfigure, operation_unblock ), NULL ); - VIPS_ARG_BOOL( class, "leak", 5, - _( "Leak" ), - _( "Report any leaks on exit" ), - VIPS_ARGUMENT_OPTIONAL_INPUT, - G_STRUCT_OFFSET( VipsConfigure, leak ), - FALSE ); - - VIPS_ARG_BOOL( class, "profile", 5, - _( "Profile" ), - _( "Write profiling data on exit" ), - VIPS_ARGUMENT_OPTIONAL_INPUT, - G_STRUCT_OFFSET( VipsConfigure, profile ), - FALSE ); - VIPS_ARG_INT( class, "concurrency", 5, _( "Concurrency" ), _( "Set threadpool size" ), @@ -181,14 +167,26 @@ vips_configure_class_init( VipsConfigureClass *class ) G_STRUCT_OFFSET( VipsConfigure, concurrency ), -1 ); + VIPS_ARG_INT64( class, "pipe_read_limit", 5, + _( "Pipe read limit" ), + _( "Maxiumum number of bytes to buffer for pipe read" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, pipe_read_limit ), + -1 ); - /* Max size of pipe. - */ - int64 pipe_read_limit; + VIPS_ARG_INT( class, "cache_max", 5, + _( "Cache max size" ), + _( "Maxium number of operations to cache" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, cache_max ), + -1 ); - /* Trace libvips operation cache actions. - */ - gboolean cache_trace; + VIPS_ARG_INT( class, "cache_max_mem", 5, + _( "Cache max memory size" ), + _( "Maxium number of operations to cache" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, cache_max ), + -1 ); /* Number of recent operations to cache. */ @@ -208,6 +206,7 @@ static void vips_configure_init( VipsConfigure *configure ) { configure->concurrency = -1; + configure->pipe_read_limit = -1; } /** From f8bdc9a990f90d4870c386db67d525ba483d5a0f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 12 Apr 2022 14:33:05 +0100 Subject: [PATCH 5/6] fix compile errors --- libvips/include/vips/object.h | 13 ------------- libvips/iofuncs/configure.c | 33 ++++++++++++++------------------- libvips/iofuncs/source.c | 1 + 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 757144dfdd..9b029a3850 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -197,19 +197,6 @@ VIPS_ARGUMENT_OPTIONAL_OUTPUT Eg. the x pos of the image minimum pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \ } -#define VIPS_ARG_INT64( CLASS, NAME, PRIORITY, LONG, DESC, \ - FLAGS, OFFSET, MIN, MAX, VALUE ) { \ - GParamSpec *pspec; \ - \ - pspec = g_param_spec_int64( (NAME), (LONG), (DESC), \ - (MIN), (MAX), (VALUE), \ - (GParamFlags) (G_PARAM_READWRITE) );\ - g_object_class_install_property( G_OBJECT_CLASS( CLASS ), \ - vips_argument_get_id(), pspec ); \ - vips_object_class_install_argument( VIPS_OBJECT_CLASS( CLASS ), \ - pspec, (VipsArgumentFlags) (FLAGS), (PRIORITY), (OFFSET) ); \ -} - #define VIPS_ARG_ENUM( CLASS, NAME, PRIORITY, LONG, DESC, \ FLAGS, OFFSET, TYPE, VALUE ) { \ GParamSpec *pspec; \ diff --git a/libvips/iofuncs/configure.c b/libvips/iofuncs/configure.c index 053c018b68..3837ce4a0d 100644 --- a/libvips/iofuncs/configure.c +++ b/libvips/iofuncs/configure.c @@ -165,40 +165,35 @@ vips_configure_class_init( VipsConfigureClass *class ) _( "Set threadpool size" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, concurrency ), - -1 ); + 0, 0, 1024 ); - VIPS_ARG_INT64( class, "pipe_read_limit", 5, + VIPS_ARG_UINT64( class, "pipe_read_limit", 6, _( "Pipe read limit" ), _( "Maxiumum number of bytes to buffer for pipe read" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, pipe_read_limit ), - -1 ); + 0, 1024L * 1024L * 1024L, 1024L * 1024L * 1024L * 1024L ); - VIPS_ARG_INT( class, "cache_max", 5, + VIPS_ARG_INT( class, "cache_max", 7, _( "Cache max size" ), _( "Maxium number of operations to cache" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, cache_max ), - -1 ); + 0, 100, 100000 ); - VIPS_ARG_INT( class, "cache_max_mem", 5, + VIPS_ARG_UINT64( class, "cache_max_mem", 8, _( "Cache max memory size" ), - _( "Maxium number of operations to cache" ), + _( "Maxium amount of memory for the operation cache" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, cache_max ), - -1 ); - - /* Number of recent operations to cache. - */ - int cache_max; - - /* Maximum memory to use for operation caching. - */ - int64 cache_max_mem; + 0, 100 * 1024L * 1024L, 1024L * 1024L * 1024L * 1024L ); - /* Maximum number of open files we allow in the cache. - */ - int cache_max_files; + VIPS_ARG_INT( class, "cache_max_files", 9, + _( "Cache max open files" ), + _( "Maxium number of open files in operation cache" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsConfigure, cache_max_files ), + 0, 100, 100000 ); } diff --git a/libvips/iofuncs/source.c b/libvips/iofuncs/source.c index 4eb8249c90..2214b7e0d5 100644 --- a/libvips/iofuncs/source.c +++ b/libvips/iofuncs/source.c @@ -1,3 +1,4 @@ +/* A byte source/sink .. it can be a pipe, file descriptor, memory area, * socket, node.js stream, etc. * * 19/6/14 From 436302949d548c449c3da15749d7396e6e5f3145 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 12 Apr 2022 18:55:36 +0100 Subject: [PATCH 6/6] oops more --- libvips/iofuncs/configure.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libvips/iofuncs/configure.c b/libvips/iofuncs/configure.c index 3837ce4a0d..98aada95dc 100644 --- a/libvips/iofuncs/configure.c +++ b/libvips/iofuncs/configure.c @@ -165,35 +165,35 @@ vips_configure_class_init( VipsConfigureClass *class ) _( "Set threadpool size" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, concurrency ), - 0, 0, 1024 ); + 0, 1024, 0 ); VIPS_ARG_UINT64( class, "pipe_read_limit", 6, _( "Pipe read limit" ), _( "Maxiumum number of bytes to buffer for pipe read" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, pipe_read_limit ), - 0, 1024L * 1024L * 1024L, 1024L * 1024L * 1024L * 1024L ); + 0, 1024L * 1024L * 1024L * 1024L, 1024L * 1024L * 1024L ); VIPS_ARG_INT( class, "cache_max", 7, _( "Cache max size" ), _( "Maxium number of operations to cache" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, cache_max ), - 0, 100, 100000 ); + 0, 100000, 100 ); VIPS_ARG_UINT64( class, "cache_max_mem", 8, _( "Cache max memory size" ), _( "Maxium amount of memory for the operation cache" ), VIPS_ARGUMENT_OPTIONAL_INPUT, - G_STRUCT_OFFSET( VipsConfigure, cache_max ), - 0, 100 * 1024L * 1024L, 1024L * 1024L * 1024L * 1024L ); + G_STRUCT_OFFSET( VipsConfigure, cache_max_mem ), + 0, 1024L * 1024L * 1024L * 1024L, 100 * 1024L * 1024L ); VIPS_ARG_INT( class, "cache_max_files", 9, _( "Cache max open files" ), _( "Maxium number of open files in operation cache" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsConfigure, cache_max_files ), - 0, 100, 100000 ); + 0, 100000, 100 ); } @@ -201,7 +201,10 @@ static void vips_configure_init( VipsConfigure *configure ) { configure->concurrency = -1; - configure->pipe_read_limit = -1; + configure->pipe_read_limit = 1024L * 1024L * 1024L; + configure->cache_max = 100; + configure->cache_max_mem = 100 * 1024L * 1024L; + configure->cache_max_files = 100; } /**