Unbroke HTTP get for some corner cases, thanks to Thickbrick again.

This commit is contained in:
Siana Gearz
2011-01-05 20:37:01 +01:00
parent e89db0b4b1
commit a919514692
2 changed files with 46 additions and 16 deletions

View File

@@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
# can be removed when we use full paths for all libraries.
cmake_policy(SET CMP0003 OLD)
set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING
set(ROOT_PROJECT_NAME "Singularity" CACHE STRING
"The root project/makefile/solution name. Defaults to SecondLife.")
project(${ROOT_PROJECT_NAME})

View File

@@ -1427,31 +1427,61 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
{
// get length of stream:
data_size = buffer->countAfter(channels.in(), NULL);
LL_DEBUGS("Texture") << "HTTP RECEIVED: " << mID.asString() << " Bytes: " << data_size << LL_ENDL;
if (data_size > 0)
{
// *TODO: set the formatted image data here directly to avoid the copy
mBuffer = new U8[data_size];
buffer->readAfter(channels.in(), NULL, mBuffer, data_size);
if (data_size < mRequestedSize && mRequestedDiscard == 0)
bool clean_data = false;
bool done = false;
if (!partial)
{
mHaveAllData = TRUE;
// we got the whole image in one go
done = true;
clean_data = true;
}
else if (data_size < mRequestedSize)
{
// we have the whole image
done = true;
}
else if (data_size == mRequestedSize)
{
if (mRequestedDiscard <= 0)
{
done = true;
}
else
{
// this is the normal case where we get the data we requested,
// but still need to request more data.
}
}
else if (data_size > mRequestedSize)
{
LL_DEBUGS("Texture") << "Extra data received: got " << data_size << " bytes (requested: " << mRequestedSize << " ) for texture: " << mID.asString() << LL_ENDL;
data_size = mRequestedSize;
// *TODO: This shouldn't be happening any more
llwarns << "data_size = " << data_size << " > requested: " << mRequestedSize << llendl;
done = true;
clean_data = true;
llassert_always(mDecodeHandle == 0);
}
mBufferSize += data_size;
}
else
{
// We requested data but received none (and no error),
// so presumably we have all of it
if (clean_data)
{
resetFormattedData(); // discard any previous data we had
llassert(mBufferSize == 0);
}
if (done)
{
mHaveAllData = TRUE;
mRequestedDiscard = 0;
}
mRequestedSize = data_size;
// *TODO: set the formatted image data here directly to avoid the copy
mBuffer = new U8[data_size];
buffer->readAfter(channels.in(), NULL, mBuffer, data_size);
mBufferSize += data_size;
mRequestedSize = data_size;
}
}
else
{