SH-4184 Conversion to llcorehttp. Remove unneeded responder

Mon, 03 Jun 2013 13:54:15 -0400

author
Monty Brandenberg <monty@lindenlab.com>
date
Mon, 03 Jun 2013 13:54:15 -0400
changeset 40679
853a34b928f7
parent 40677
e1ef342c2a58
child 40680
90e5504bc860

SH-4184 Conversion to llcorehttp. Remove unneeded responder
classes (moved to Handlers).

indra/newview/llmeshrepository.cpp file | annotate | diff | revisions
     1.1 --- a/indra/newview/llmeshrepository.cpp	Wed May 08 18:37:08 2013 -0400
     1.2 +++ b/indra/newview/llmeshrepository.cpp	Mon Jun 03 13:54:15 2013 -0400
     1.3 @@ -218,7 +218,8 @@
     1.4  	LLMeshHandlerBase()
     1.5  		: LLCore::HttpHandler(),
     1.6  		  mMeshParams(),
     1.7 -		  mProcessed(false)
     1.8 +		  mProcessed(false),
     1.9 +		  mHttpHandle(LLCORE_HTTP_HANDLE_INVALID)
    1.10  	{}
    1.11  	virtual ~LLMeshHandlerBase();
    1.12  
    1.13 @@ -365,154 +366,6 @@
    1.14  	U32			mOffset;
    1.15  };
    1.16  
    1.17 -	
    1.18 -class LLMeshHeaderResponder : public LLCurl::Responder
    1.19 -{
    1.20 -public:
    1.21 -	LLVolumeParams mMeshParams;
    1.22 -	bool mProcessed;
    1.23 -
    1.24 -	LLMeshHeaderResponder(const LLVolumeParams& mesh_params)
    1.25 -		: mMeshParams(mesh_params)
    1.26 -	{
    1.27 -		LLMeshRepoThread::incActiveHeaderRequests();
    1.28 -		mProcessed = false;
    1.29 -	}
    1.30 -
    1.31 -	~LLMeshHeaderResponder()
    1.32 -	{
    1.33 -		if (!LLApp::isQuitting())
    1.34 -		{
    1.35 -			if (!mProcessed)
    1.36 -			{ //something went wrong, retry
    1.37 -				llwarns << "Timeout or service unavailable, retrying." << llendl;
    1.38 -				LLMeshRepository::sHTTPRetryCount++;
    1.39 -				LLMeshRepoThread::HeaderRequest req(mMeshParams);
    1.40 -				LLMutexLock lock(gMeshRepo.mThread->mMutex);
    1.41 -				gMeshRepo.mThread->mHeaderReqQ.push(req);
    1.42 -			}
    1.43 -
    1.44 -			LLMeshRepoThread::decActiveHeaderRequests();
    1.45 -		}
    1.46 -	}
    1.47 -
    1.48 -	virtual void completedRaw(U32 status, const std::string& reason,
    1.49 -							  const LLChannelDescriptors& channels,
    1.50 -							  const LLIOPipe::buffer_ptr_t& buffer);
    1.51 -
    1.52 -};
    1.53 -
    1.54 -class LLMeshLODResponder : public LLCurl::Responder
    1.55 -{
    1.56 -public:
    1.57 -	LLVolumeParams mMeshParams;
    1.58 -	S32 mLOD;
    1.59 -	U32 mRequestedBytes;
    1.60 -	U32 mOffset;
    1.61 -	bool mProcessed;
    1.62 -
    1.63 -	LLMeshLODResponder(const LLVolumeParams& mesh_params, S32 lod, U32 offset, U32 requested_bytes)
    1.64 -		: mMeshParams(mesh_params), mLOD(lod), mOffset(offset), mRequestedBytes(requested_bytes)
    1.65 -	{
    1.66 -		LLMeshRepoThread::incActiveLODRequests();
    1.67 -		mProcessed = false;
    1.68 -	}
    1.69 -
    1.70 -	~LLMeshLODResponder()
    1.71 -	{
    1.72 -		if (!LLApp::isQuitting())
    1.73 -		{
    1.74 -			if (!mProcessed)
    1.75 -			{
    1.76 -				llwarns << "Killed without being processed, retrying." << llendl;
    1.77 -				LLMeshRepository::sHTTPRetryCount++;
    1.78 -				gMeshRepo.mThread->lockAndLoadMeshLOD(mMeshParams, mLOD);
    1.79 -			}
    1.80 -			LLMeshRepoThread::decActiveLODRequests();
    1.81 -		}
    1.82 -	}
    1.83 -
    1.84 -	virtual void completedRaw(U32 status, const std::string& reason,
    1.85 -							  const LLChannelDescriptors& channels,
    1.86 -							  const LLIOPipe::buffer_ptr_t& buffer);
    1.87 -
    1.88 -};
    1.89 -
    1.90 -class LLMeshSkinInfoResponder : public LLCurl::Responder
    1.91 -{
    1.92 -public:
    1.93 -	LLUUID mMeshID;
    1.94 -	U32 mRequestedBytes;
    1.95 -	U32 mOffset;
    1.96 -	bool mProcessed;
    1.97 -
    1.98 -	LLMeshSkinInfoResponder(const LLUUID& id, U32 offset, U32 size)
    1.99 -		: mMeshID(id), mRequestedBytes(size), mOffset(offset)
   1.100 -	{
   1.101 -		mProcessed = false;
   1.102 -	}
   1.103 -
   1.104 -	~LLMeshSkinInfoResponder()
   1.105 -	{
   1.106 -		llassert(mProcessed);
   1.107 -	}
   1.108 -
   1.109 -	virtual void completedRaw(U32 status, const std::string& reason,
   1.110 -							  const LLChannelDescriptors& channels,
   1.111 -							  const LLIOPipe::buffer_ptr_t& buffer);
   1.112 -
   1.113 -};
   1.114 -
   1.115 -class LLMeshDecompositionResponder : public LLCurl::Responder
   1.116 -{
   1.117 -public:
   1.118 -	LLUUID mMeshID;
   1.119 -	U32 mRequestedBytes;
   1.120 -	U32 mOffset;
   1.121 -	bool mProcessed;
   1.122 -
   1.123 -	LLMeshDecompositionResponder(const LLUUID& id, U32 offset, U32 size)
   1.124 -		: mMeshID(id), mRequestedBytes(size), mOffset(offset)
   1.125 -	{
   1.126 -		mProcessed = false;
   1.127 -	}
   1.128 -
   1.129 -	~LLMeshDecompositionResponder()
   1.130 -	{
   1.131 -		llassert(mProcessed);
   1.132 -	}
   1.133 -
   1.134 -	virtual void completedRaw(U32 status, const std::string& reason,
   1.135 -							  const LLChannelDescriptors& channels,
   1.136 -							  const LLIOPipe::buffer_ptr_t& buffer);
   1.137 -
   1.138 -};
   1.139 -
   1.140 -class LLMeshPhysicsShapeResponder : public LLCurl::Responder
   1.141 -{
   1.142 -public:
   1.143 -	LLUUID mMeshID;
   1.144 -	U32 mRequestedBytes;
   1.145 -	U32 mOffset;
   1.146 -	bool mProcessed;
   1.147 -
   1.148 -	LLMeshPhysicsShapeResponder(const LLUUID& id, U32 offset, U32 size)
   1.149 -		: mMeshID(id), mRequestedBytes(size), mOffset(offset)
   1.150 -	{
   1.151 -		mProcessed = false;
   1.152 -	}
   1.153 -
   1.154 -	~LLMeshPhysicsShapeResponder()
   1.155 -	{
   1.156 -		llassert(mProcessed);
   1.157 -	}
   1.158 -
   1.159 -	virtual void completedRaw(U32 status, const std::string& reason,
   1.160 -							  const LLChannelDescriptors& channels,
   1.161 -							  const LLIOPipe::buffer_ptr_t& buffer);
   1.162 -
   1.163 -};
   1.164 -
   1.165  void log_upload_error(S32 status, const LLSD& content, std::string stage, std::string model_name)
   1.166  {
   1.167  	// Add notification popup.
   1.168 @@ -1005,9 +858,6 @@
   1.169  			}
   1.170  
   1.171  			//reading from VFS failed for whatever reason, fetch from sim
   1.172 -			std::vector<std::string> headers;
   1.173 -			headers.push_back("Accept: application/octet-stream");
   1.174 -
   1.175  			std::string http_url = constructUrl(mesh_id);
   1.176  			if (!http_url.empty())
   1.177  			{
   1.178 @@ -1104,9 +954,6 @@
   1.179  			}
   1.180  
   1.181  			//reading from VFS failed for whatever reason, fetch from sim
   1.182 -			std::vector<std::string> headers;
   1.183 -			headers.push_back("Accept: application/octet-stream");
   1.184 -
   1.185  			std::string http_url = constructUrl(mesh_id);
   1.186  			if (!http_url.empty())
   1.187  			{
   1.188 @@ -1202,9 +1049,6 @@
   1.189  			}
   1.190  
   1.191  			//reading from VFS failed for whatever reason, fetch from sim
   1.192 -			std::vector<std::string> headers;
   1.193 -			headers.push_back("Accept: application/octet-stream");
   1.194 -
   1.195  			std::string http_url = constructUrl(mesh_id);
   1.196  			if (!http_url.empty())
   1.197  			{
   1.198 @@ -1301,9 +1145,6 @@
   1.199  
   1.200  	//either cache entry doesn't exist or is corrupt, request header from simulator	
   1.201  	bool retval = true ;
   1.202 -	std::vector<std::string> headers;
   1.203 -	headers.push_back("Accept: application/octet-stream");
   1.204 -
   1.205  	std::string http_url = constructUrl(mesh_params.getSculptID());
   1.206  	if (!http_url.empty())
   1.207  	{
   1.208 @@ -1395,9 +1236,6 @@
   1.209  			}
   1.210  
   1.211  			//reading from VFS failed for whatever reason, fetch from sim
   1.212 -			std::vector<std::string> headers;
   1.213 -			headers.push_back("Accept: application/octet-stream");
   1.214 -
   1.215  			std::string http_url = constructUrl(mesh_id);
   1.216  			if (!http_url.empty())
   1.217  			{
   1.218 @@ -2184,270 +2022,12 @@
   1.219  
   1.220  }
   1.221  
   1.222 -void LLMeshLODResponder::completedRaw(U32 status, const std::string& reason,
   1.223 -							  const LLChannelDescriptors& channels,
   1.224 -							  const LLIOPipe::buffer_ptr_t& buffer)
   1.225 -{
   1.226 -	mProcessed = true;
   1.227 -	
   1.228 -	// thread could have already be destroyed during logout
   1.229 -	if( !gMeshRepo.mThread )
   1.230 -	{
   1.231 -		return;
   1.232 -	}
   1.233 -	
   1.234 -	S32 data_size = buffer->countAfter(channels.in(), NULL);
   1.235 -
   1.236 -	if (status < 200 || status > 400)
   1.237 -	{
   1.238 -		llwarns << status << ": " << reason << llendl;
   1.239 -	}
   1.240 -
   1.241 -	if (data_size < mRequestedBytes)
   1.242 -	{
   1.243 -		if (status == 499 || status == 503)
   1.244 -		{ //timeout or service unavailable, try again
   1.245 -			llwarns << "Timeout or service unavailable, retrying." << llendl;
   1.246 -			LLMeshRepository::sHTTPRetryCount++;
   1.247 -			gMeshRepo.mThread->loadMeshLOD(mMeshParams, mLOD);
   1.248 -		}
   1.249 -		else
   1.250 -		{
   1.251 -			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
   1.252 -			llwarns << "Unhandled status " << status << llendl;
   1.253 -		}
   1.254 -		return;
   1.255 -	}
   1.256 -
   1.257 -	LLMeshRepository::sBytesReceived += mRequestedBytes;
   1.258 -
   1.259 -	U8* data = NULL;
   1.260 -
   1.261 -	if (data_size > 0)
   1.262 -	{
   1.263 -		data = new U8[data_size];
   1.264 -		buffer->readAfter(channels.in(), NULL, data, data_size);
   1.265 -	}
   1.266 -
   1.267 -	if (gMeshRepo.mThread->lodReceived(mMeshParams, mLOD, data, data_size))
   1.268 -	{
   1.269 -		//good fetch from sim, write to VFS for caching
   1.270 -		LLVFile file(gVFS, mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLVFile::WRITE);
   1.271 -
   1.272 -		S32 offset = mOffset;
   1.273 -		S32 size = mRequestedBytes;
   1.274 -
   1.275 -		if (file.getSize() >= offset+size)
   1.276 -		{
   1.277 -			file.seek(offset);
   1.278 -			file.write(data, size);
   1.279 -			LLMeshRepository::sCacheBytesWritten += size;
   1.280 -		}
   1.281 -	}
   1.282 -
   1.283 -	delete [] data;
   1.284 -}
   1.285 -
   1.286 -void LLMeshSkinInfoResponder::completedRaw(U32 status, const std::string& reason,
   1.287 -							  const LLChannelDescriptors& channels,
   1.288 -							  const LLIOPipe::buffer_ptr_t& buffer)
   1.289 -{
   1.290 -	mProcessed = true;
   1.291 -
   1.292 -	// thread could have already be destroyed during logout
   1.293 -	if( !gMeshRepo.mThread )
   1.294 -	{
   1.295 -		return;
   1.296 -	}
   1.297 -
   1.298 -	S32 data_size = buffer->countAfter(channels.in(), NULL);
   1.299 -
   1.300 -	if (status < 200 || status > 400)
   1.301 -	{
   1.302 -		llwarns << status << ": " << reason << llendl;
   1.303 -	}
   1.304 -
   1.305 -	if (data_size < mRequestedBytes)
   1.306 -	{
   1.307 -		if (status == 499 || status == 503)
   1.308 -		{ //timeout or service unavailable, try again
   1.309 -			llwarns << "Timeout or service unavailable, retrying." << llendl;
   1.310 -			LLMeshRepository::sHTTPRetryCount++;
   1.311 -			gMeshRepo.mThread->loadMeshSkinInfo(mMeshID);
   1.312 -		}
   1.313 -		else
   1.314 -		{
   1.315 -			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
   1.316 -			llwarns << "Unhandled status " << status << llendl;
   1.317 -		}
   1.318 -		return;
   1.319 -	}
   1.320 -
   1.321 -	LLMeshRepository::sBytesReceived += mRequestedBytes;
   1.322 -
   1.323 -	U8* data = NULL;
   1.324 -
   1.325 -	if (data_size > 0)
   1.326 -	{
   1.327 -		data = new U8[data_size];
   1.328 -		buffer->readAfter(channels.in(), NULL, data, data_size);
   1.329 -	}
   1.330 -
   1.331 -	if (gMeshRepo.mThread->skinInfoReceived(mMeshID, data, data_size))
   1.332 -	{
   1.333 -		//good fetch from sim, write to VFS for caching
   1.334 -		LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
   1.335 -
   1.336 -		S32 offset = mOffset;
   1.337 -		S32 size = mRequestedBytes;
   1.338 -
   1.339 -		if (file.getSize() >= offset+size)
   1.340 -		{
   1.341 -			LLMeshRepository::sCacheBytesWritten += size;
   1.342 -			file.seek(offset);
   1.343 -			file.write(data, size);
   1.344 -		}
   1.345 -	}
   1.346 -
   1.347 -	delete [] data;
   1.348 -}
   1.349 -
   1.350 -void LLMeshDecompositionResponder::completedRaw(U32 status, const std::string& reason,
   1.351 -							  const LLChannelDescriptors& channels,
   1.352 -							  const LLIOPipe::buffer_ptr_t& buffer)
   1.353 -{
   1.354 -	mProcessed = true;
   1.355 -	
   1.356 -	if( !gMeshRepo.mThread )
   1.357 -	{
   1.358 -		return;
   1.359 -	}
   1.360 -
   1.361 -	S32 data_size = buffer->countAfter(channels.in(), NULL);
   1.362 -
   1.363 -	if (status < 200 || status > 400)
   1.364 -	{
   1.365 -		llwarns << status << ": " << reason << llendl;
   1.366 -	}
   1.367 -
   1.368 -	if (data_size < mRequestedBytes)
   1.369 -	{
   1.370 -		if (status == 499 || status == 503)
   1.371 -		{ //timeout or service unavailable, try again
   1.372 -			llwarns << "Timeout or service unavailable, retrying." << llendl;
   1.373 -			LLMeshRepository::sHTTPRetryCount++;
   1.374 -			gMeshRepo.mThread->loadMeshDecomposition(mMeshID);
   1.375 -		}
   1.376 -		else
   1.377 -		{
   1.378 -			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
   1.379 -			llwarns << "Unhandled status " << status << llendl;
   1.380 -		}
   1.381 -		return;
   1.382 -	}
   1.383 -
   1.384 -	LLMeshRepository::sBytesReceived += mRequestedBytes;
   1.385 -
   1.386 -	U8* data = NULL;
   1.387 -
   1.388 -	if (data_size > 0)
   1.389 -	{
   1.390 -		data = new U8[data_size];
   1.391 -		buffer->readAfter(channels.in(), NULL, data, data_size);
   1.392 -	}
   1.393 -
   1.394 -	if (gMeshRepo.mThread->decompositionReceived(mMeshID, data, data_size))
   1.395 -	{
   1.396 -		//good fetch from sim, write to VFS for caching
   1.397 -		LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
   1.398 -
   1.399 -		S32 offset = mOffset;
   1.400 -		S32 size = mRequestedBytes;
   1.401 -
   1.402 -		if (file.getSize() >= offset+size)
   1.403 -		{
   1.404 -			LLMeshRepository::sCacheBytesWritten += size;
   1.405 -			file.seek(offset);
   1.406 -			file.write(data, size);
   1.407 -		}
   1.408 -	}
   1.409 -
   1.410 -	delete [] data;
   1.411 -}
   1.412 -
   1.413 -void LLMeshPhysicsShapeResponder::completedRaw(U32 status, const std::string& reason,
   1.414 -							  const LLChannelDescriptors& channels,
   1.415 -							  const LLIOPipe::buffer_ptr_t& buffer)
   1.416 -{
   1.417 -	mProcessed = true;
   1.418 -
   1.419 -	// thread could have already be destroyed during logout
   1.420 -	if( !gMeshRepo.mThread )
   1.421 -	{
   1.422 -		return;
   1.423 -	}
   1.424 -
   1.425 -	S32 data_size = buffer->countAfter(channels.in(), NULL);
   1.426 -
   1.427 -	if (status < 200 || status > 400)
   1.428 -	{
   1.429 -		llwarns << status << ": " << reason << llendl;
   1.430 -	}
   1.431 -
   1.432 -	if (data_size < mRequestedBytes)
   1.433 -	{
   1.434 -		if (status == 499 || status == 503)
   1.435 -		{ //timeout or service unavailable, try again
   1.436 -			llwarns << "Timeout or service unavailable, retrying." << llendl;
   1.437 -			LLMeshRepository::sHTTPRetryCount++;
   1.438 -			gMeshRepo.mThread->loadMeshPhysicsShape(mMeshID);
   1.439 -		}
   1.440 -		else
   1.441 -		{
   1.442 -			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
   1.443 -			llwarns << "Unhandled status " << status << llendl;
   1.444 -		}
   1.445 -		return;
   1.446 -	}
   1.447 -
   1.448 -	LLMeshRepository::sBytesReceived += mRequestedBytes;
   1.449 -
   1.450 -	U8* data = NULL;
   1.451 -
   1.452 -	if (data_size > 0)
   1.453 -	{
   1.454 -		data = new U8[data_size];
   1.455 -		buffer->readAfter(channels.in(), NULL, data, data_size);
   1.456 -	}
   1.457 -
   1.458 -	if (gMeshRepo.mThread->physicsShapeReceived(mMeshID, data, data_size))
   1.459 -	{
   1.460 -		//good fetch from sim, write to VFS for caching
   1.461 -		LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
   1.462 -
   1.463 -		S32 offset = mOffset;
   1.464 -		S32 size = mRequestedBytes;
   1.465 -
   1.466 -		if (file.getSize() >= offset+size)
   1.467 -		{
   1.468 -			LLMeshRepository::sCacheBytesWritten += size;
   1.469 -			file.seek(offset);
   1.470 -			file.write(data, size);
   1.471 -		}
   1.472 -	}
   1.473 -
   1.474 -	delete [] data;
   1.475 -}
   1.476 -
   1.477 -	
   1.478  LLMeshHandlerBase::~LLMeshHandlerBase()
   1.479  {}
   1.480  
   1.481 -
   1.482  void LLMeshHandlerBase::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response)
   1.483  {
   1.484  	mProcessed = true;
   1.485 -
   1.486  	LLCore::HttpStatus status(response->getStatus());
   1.487  	if (! status)
   1.488  	{
   1.489 @@ -2506,7 +2086,6 @@
   1.490  	}
   1.491  }
   1.492  
   1.493 -
   1.494  void LLMeshHeaderHandler::processFailure(LLCore::HttpStatus status)
   1.495  {
   1.496  	LL_WARNS("Mesh") << "MESH:  Processing Failure" << LL_ENDL;
   1.497 @@ -2525,7 +2104,6 @@
   1.498  	}
   1.499  }
   1.500  
   1.501 -
   1.502  void LLMeshHeaderHandler::processData(LLCore::BufferArray * body, U8 * data, S32 data_size)
   1.503  {
   1.504  	// LL_WARNS("Mesh") << "MESH:  Processing Data" << LL_ENDL;
   1.505 @@ -2596,7 +2174,6 @@
   1.506  	}
   1.507  }
   1.508  
   1.509 -
   1.510  LLMeshLODHandler::~LLMeshLODHandler()
   1.511  {
   1.512  	if (! LLApp::isQuitting())
   1.513 @@ -2646,7 +2223,6 @@
   1.514  	}
   1.515  }
   1.516  
   1.517 -
   1.518  LLMeshSkinInfoHandler::~LLMeshSkinInfoHandler()
   1.519  {
   1.520  		llassert(mProcessed);
   1.521 @@ -2687,7 +2263,6 @@
   1.522  	}
   1.523  }
   1.524  
   1.525 -
   1.526  LLMeshDecompositionHandler::~LLMeshDecompositionHandler()
   1.527  {
   1.528  		llassert(mProcessed);
   1.529 @@ -2728,7 +2303,6 @@
   1.530  	}
   1.531  }
   1.532  
   1.533 -
   1.534  LLMeshPhysicsShapeHandler::~LLMeshPhysicsShapeHandler()
   1.535  {
   1.536  		llassert(mProcessed);
   1.537 @@ -2750,7 +2324,6 @@
   1.538  	}
   1.539  }
   1.540  
   1.541 -	
   1.542  void LLMeshPhysicsShapeHandler::processData(LLCore::BufferArray * body, U8 * data, S32 data_size)
   1.543  {
   1.544  	if (gMeshRepo.mThread->physicsShapeReceived(mMeshID, data, data_size))
   1.545 @@ -2770,134 +2343,6 @@
   1.546  	}
   1.547  }
   1.548  
   1.549 -
   1.550 -void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
   1.551 -							  const LLChannelDescriptors& channels,
   1.552 -							  const LLIOPipe::buffer_ptr_t& buffer)
   1.553 -{
   1.554 -	mProcessed = true;
   1.555 -
   1.556 -	// thread could have already be destroyed during logout
   1.557 -	if( !gMeshRepo.mThread )
   1.558 -	{
   1.559 -		return;
   1.560 -	}
   1.561 -
   1.562 -	if (status < 200 || status > 400)
   1.563 -	{
   1.564 -		//llwarns
   1.565 -		//	<< "Header responder failed with status: "
   1.566 -		//	<< status << ": " << reason << llendl;
   1.567 -
   1.568 -		// 503 (service unavailable) or 499 (timeout)
   1.569 -		// can be due to server load and can be retried
   1.570 -
   1.571 -		// TODO*: Add maximum retry logic, exponential backoff
   1.572 -		// and (somewhat more optional than the others) retries
   1.573 -		// again after some set period of time
   1.574 -
   1.575 -		llassert(status == 503 || status == 499);
   1.576 -
   1.577 -		if (status == 503 || status == 499)
   1.578 -		{ //retry
   1.579 -			llwarns << "Timeout or service unavailable, retrying." << llendl;
   1.580 -			LLMeshRepository::sHTTPRetryCount++;
   1.581 -			LLMeshRepoThread::HeaderRequest req(mMeshParams);
   1.582 -			LLMutexLock lock(gMeshRepo.mThread->mMutex);
   1.583 -			gMeshRepo.mThread->mHeaderReqQ.push(req);
   1.584 -
   1.585 -			return;
   1.586 -		}
   1.587 -		else
   1.588 -		{
   1.589 -			llwarns << "Unhandled status." << llendl;
   1.590 -		}
   1.591 -	}
   1.592 -
   1.593 -	S32 data_size = buffer->countAfter(channels.in(), NULL);
   1.594 -
   1.595 -	U8* data = NULL;
   1.596 -
   1.597 -	if (data_size > 0)
   1.598 -	{
   1.599 -		data = new U8[data_size];
   1.600 -		buffer->readAfter(channels.in(), NULL, data, data_size);
   1.601 -	}
   1.602 -
   1.603 -	LLMeshRepository::sBytesReceived += llmin(data_size, MESH_HEADER_SIZE);
   1.604 -
   1.605 -	bool success = gMeshRepo.mThread->headerReceived(mMeshParams, data, data_size);
   1.606 -	
   1.607 -	llassert(success);
   1.608 -
   1.609 -	if (!success)
   1.610 -	{
   1.611 -		llwarns
   1.612 -			<< "Unable to parse mesh header: "
   1.613 -			<< status << ": " << reason << llendl;
   1.614 -	}
   1.615 -	else if (data && data_size > 0)
   1.616 -	{
   1.617 -		//header was successfully retrieved from sim, cache in vfs
   1.618 -		LLUUID mesh_id = mMeshParams.getSculptID();
   1.619 -		LLSD header = gMeshRepo.mThread->mMeshHeader[mesh_id];
   1.620 -
   1.621 -		S32 version = header["version"].asInteger();
   1.622 -
   1.623 -		if (version <= MAX_MESH_VERSION)
   1.624 -		{
   1.625 -			std::stringstream str;
   1.626 -
   1.627 -			S32 lod_bytes = 0;
   1.628 -
   1.629 -			for (U32 i = 0; i < LLModel::LOD_PHYSICS; ++i)
   1.630 -			{ //figure out how many bytes we'll need to reserve in the file
   1.631 -				std::string lod_name = header_lod[i];
   1.632 -				lod_bytes = llmax(lod_bytes, header[lod_name]["offset"].asInteger()+header[lod_name]["size"].asInteger());
   1.633 -			}
   1.634 -		
   1.635 -			//just in case skin info or decomposition is at the end of the file (which it shouldn't be)
   1.636 -			lod_bytes = llmax(lod_bytes, header["skin"]["offset"].asInteger() + header["skin"]["size"].asInteger());
   1.637 -			lod_bytes = llmax(lod_bytes, header["physics_convex"]["offset"].asInteger() + header["physics_convex"]["size"].asInteger());
   1.638 -
   1.639 -			S32 header_bytes = (S32) gMeshRepo.mThread->mMeshHeaderSize[mesh_id];
   1.640 -			S32 bytes = lod_bytes + header_bytes; 
   1.641 -
   1.642 -		
   1.643 -			//it's possible for the remote asset to have more data than is needed for the local cache
   1.644 -			//only allocate as much space in the VFS as is needed for the local cache
   1.645 -			data_size = llmin(data_size, bytes);
   1.646 -
   1.647 -			LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH, LLVFile::WRITE);
   1.648 -			if (file.getMaxSize() >= bytes || file.setMaxSize(bytes))
   1.649 -			{
   1.650 -				LLMeshRepository::sCacheBytesWritten += data_size;
   1.651 -
   1.652 -				file.write((const U8*) data, data_size);
   1.653 -			
   1.654 -				//zero out the rest of the file 
   1.655 -				U8 block[MESH_HEADER_SIZE];
   1.656 -				memset(block, 0, MESH_HEADER_SIZE);
   1.657 -
   1.658 -				while (bytes-file.tell() > MESH_HEADER_SIZE)
   1.659 -				{
   1.660 -					file.write(block, MESH_HEADER_SIZE);
   1.661 -				}
   1.662 -
   1.663 -				S32 remaining = bytes-file.tell();
   1.664 -
   1.665 -				if (remaining > 0)
   1.666 -				{
   1.667 -					file.write(block, remaining);
   1.668 -				}
   1.669 -			}
   1.670 -		}
   1.671 -	}
   1.672 -
   1.673 -	delete [] data;
   1.674 -}
   1.675 -
   1.676 -
   1.677  LLMeshRepository::LLMeshRepository()
   1.678  : mMeshMutex(NULL),
   1.679    mMeshThreadCount(0),

mercurial