id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
2647	WMS driver fails when some blocks are already in block cache	rouault	rouault	"With the following dataset test.xml:

{{{
<GDAL_WMS>
    <Service name=""WMS"">
        <Version>1.1.1</Version>
        <ServerUrl>http://127.0.0.1:8080/wms.cgi?</ServerUrl>
        <SRS>EPSG:4326</SRS>
        <ImageFormat>image/jpeg</ImageFormat>
        <Layers>modis,global_mosaic</Layers>
        <Styles></Styles>
    </Service>
    <DataWindow>
        <UpperLeftX>-180.0</UpperLeftX>
        <UpperLeftY>90.0</UpperLeftY>
        <LowerRightX>180.0</LowerRightX>
        <LowerRightY>-90.0</LowerRightY>
        <SizeX>2666666</SizeX>
        <SizeY>1333333</SizeY>
    </DataWindow>
    <Projection>EPSG:4326</Projection>
    <BandsCount>3</BandsCount>
</GDAL_WMS>
}}}

where wms.cgi is a fake CGI WMS server (to avoid being blacklisted by online web server) that always returns a 1024x1024 black JPEG image, the current WMS driver will fail when doing :

apps/gdal_translate -outsize 0.2% 0.2% test.xml test.tif

The error will be ""GDALWMS: GetDataRef returned NULL""

The reason is that because of the default values for GDAL_CACHEMAX and GDAL_SWATH_SIZE, GDALDatasetCopyWholeRaster() will sometimes cause the same WMS request to be issued serveral times for reading the same block but in different bands. But ReadBlockFromFile() in the WMS driver is not ready to deal with that.

Fix to follow."	defect	closed	normal	1.6.0	default	unspecified	normal	fixed	wms	nowakpl
