try to handle mmap failing in source
Some filesystems have mmap disabled. Make vips_source_map() fall back to read if mmap fails. See https://github.com/libvips/libvips/discussions/2415
This commit is contained in:
parent
f2dd4471eb
commit
cfd9dc3f01
@ -1002,23 +1002,26 @@ vips_source_map( VipsSource *source, size_t *length_out )
|
|||||||
vips_source_test_features( source ) )
|
vips_source_test_features( source ) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
if( !source->data ) {
|
/* Try to map the file into memory, if possible. Some filesystems have
|
||||||
/* Seekable descriptors can simply be mapped. Seekable sources
|
* mmap disabled, so we don't give up if this fails.
|
||||||
* can be read. All other sources must be streamed into memory.
|
*/
|
||||||
*/
|
if( !source->data &&
|
||||||
if( vips_source_is_mappable( source ) ) {
|
vips_source_is_mappable( source ) )
|
||||||
if( vips_source_descriptor_to_memory( source ) )
|
(void) vips_source_descriptor_to_memory( source );
|
||||||
return( NULL );
|
|
||||||
}
|
/* If it's not a pipe, we can rewind, get the length, and read the
|
||||||
else if( !source->is_pipe ) {
|
* whole thing.
|
||||||
if( vips_source_read_to_memory( source ) )
|
*/
|
||||||
return( NULL );
|
if( !source->data &&
|
||||||
}
|
!source->is_pipe &&
|
||||||
else {
|
vips_source_read_to_memory( source ) )
|
||||||
if( vips_source_pipe_read_to_position( source, -1 ) )
|
return( NULL );
|
||||||
return( NULL );
|
|
||||||
}
|
/* We don't know the length and must read and assemble in chunks.
|
||||||
}
|
*/
|
||||||
|
if( !source->data &&
|
||||||
|
vips_source_pipe_read_to_position( source, -1 ) )
|
||||||
|
return( NULL );
|
||||||
|
|
||||||
if( length_out )
|
if( length_out )
|
||||||
*length_out = source->length;
|
*length_out = source->length;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user