[Gdal-dev] Re: image data flushing (clean rebuild needed)

Frank Warmerdam warmerdam at pobox.com
Wed Apr 30 09:10:35 EDT 2003


Andrey Kiselev wrote:
> Frank,
> 
> On Tue, Mar 18, 2003 at 01:11:23AM -0500, Frank Warmerdam wrote:
> 
>>Gillian was encountering a problem where some formats implemented on top the
>>RawRasterBand and related classes were not properly fflushing data to disk
>>when the GDALRasterBand::FlushCache() method was called.
>>
>>To correct this I made the GDALRasterBand::FlushCache() method virtual and
>>implemented it (to call VSIFFlussh()) for the RawRasterBand class.   As
>>a result of changing the method to be virtual anyone updating GDAL from CVS
>>should do a clean build (make clean; make).  Any change to the virtual
>>function table requires a complete recompile.
> 
> 
> I have found a problem with this method. Many raw datasets close image
> file in dataset destructors and RawRasterBand::FlushCache() called for the
> already closed file. Probably VSIFFlush() call should be moved to
> IWriteBlock() method for those datasets which cause problems?

Andrey,

Good point.  I don't think moving VSIFFlush() to IWriteBlock() is a good
idea because fflush() can potentially cause a substantial pause as data
is written to physical disk, thus screwing up the benefits of write buffering
on the stream.

Instead, I would like you to change things so that RawRasterBand keeps a
"dirty" flag indicating there is unflushed output written, this flag should
be set true in IWriteBlock() but initialized to false.  In
RawRasterBand::FlushCache() only do the VSIFFlush() call if the flag is true,
and then clear it of course.

This will ensure that file level flushing is only done when there is something
pending.  Dataset classes derived from RawDataset (or otherwise using
RawRasterBand) just need to call FlushCache() in their destructors before
closing the file.

Thanks for taking care of this.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list