fix tmp file handling on Windows

it wasnt working, breaking handling of non-vips files over 100mb on
Windows
This commit is contained in:
John Cupitt 2012-07-05 09:54:59 +01:00
parent ec53b1af74
commit 34f25dabd5
4 changed files with 26 additions and 6 deletions

View File

@ -1,6 +1,8 @@
18/6/12 started 7.28.9
- slightly more memory debugging output
- remove references to the static bicubic interpolator from the docs
- fix temp file handling on Windows --- was breaking for non-vips files
over 100mb
18/6/12 started 7.28.8
- fixes for centos5 portability

View File

@ -1563,7 +1563,7 @@ vips_image_new_array( int xsize, int ysize )
* @delete_on_close: format of file
*
* Sets the delete_on_close flag for the image. If this flag is set, when
* @image is finalized the filename held in @image->filename at the time of
* @image is finalized, the filename held in @image->filename at the time of
* this call is unlinked.
*
* This function is clearly extremely dangerous, use with great caution.
@ -1900,9 +1900,20 @@ vips_image_write_line( VipsImage *image, int ypos, VipsPel *linebuffer )
static int
vips_image_rewind_output( VipsImage *image )
{
int fd;
#ifdef DEBUG_IO
printf( "vips_image_rewind_output: %s\n", image->filename );
#endif/*DEBUG_IO*/
printf( "vips_image_rewind_output: %s\n", image->filename );
/* If this is a temp OPENOUT image on Windows, rewinding will close
* the FD and delete the file (since we set O_TEMP).
*
* We open the file again with a temp handle here to make sure it
* stays alive until the "rd" open we do just below.
*/
if( (fd = vips__open_image_read( image->filename )) == -1 )
return( -1 );
/* Free any resources the image holds and reset to a base
* state.
@ -1918,9 +1929,16 @@ vips_image_rewind_output( VipsImage *image )
vips_error( "VipsImage",
_( "auto-rewind for %s failed" ),
image->filename );
vips_tracked_close( fd );
return( -1 );
}
/* Now we've reopened, we can drop the ref we made.
*/
vips_tracked_close( fd );
printf( "vips_image_rewind_output: deleteing temp\n" );
/* Now we've finished writing and reopened as read, we can
* delete-on-close.
*

View File

@ -356,9 +356,9 @@ vips_tracked_open( const char *pathname, int flags, ... )
vips_tracked_files += 1;
#ifdef DEBUG
#endif /*DEBUG*/
printf( "vips_tracked_open: %s = %d (%d)\n",
pathname, fd, vips_tracked_files );
#endif /*DEBUG*/
g_mutex_unlock( vips_tracked_mutex );
@ -391,8 +391,8 @@ vips_tracked_close( int fd )
vips_tracked_files -= 1;
#ifdef DEBUG
printf( "vips_tracked_close: %d (%d)\n", fd, vips_tracked_files );
#endif /*DEBUG*/
printf( "vips_tracked_close: %d (%d)\n", fd, vips_tracked_files );
g_mutex_unlock( vips_tracked_mutex );

View File

@ -1212,10 +1212,10 @@ static void
vips_object_real_rewind( VipsObject *object )
{
#ifdef DEBUG
printf( "vips_object_rewind\n" );
#endif /*DEBUG*/
printf( "vips_object_real_rewind\n" );
vips_object_print_name( object );
printf( "\n" );
#endif /*DEBUG*/
g_object_run_dispose( G_OBJECT( object ) );