aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llhttpassetstorage.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llmessage/llhttpassetstorage.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llmessage/llhttpassetstorage.cpp')
-rw-r--r--linden/indra/llmessage/llhttpassetstorage.cpp76
1 files changed, 61 insertions, 15 deletions
diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp
index 74f5271..80598c6 100644
--- a/linden/indra/llmessage/llhttpassetstorage.cpp
+++ b/linden/indra/llmessage/llhttpassetstorage.cpp
@@ -422,11 +422,8 @@ void LLHTTPAssetStorage::_init(const char *web_host, const char *local_web_host,
422 mLocalBaseURL = local_web_host; 422 mLocalBaseURL = local_web_host;
423 mHostName = host_name; 423 mHostName = host_name;
424 424
425 // Do not change this "unless you are familiar with and mean to control 425 // curl_global_init moved to LLCurl::initClass()
426 // internal operations of libcurl" 426
427 // - http://curl.haxx.se/libcurl/c/curl_global_init.html
428 curl_global_init(CURL_GLOBAL_ALL);
429
430 mCurlMultiHandle = curl_multi_init(); 427 mCurlMultiHandle = curl_multi_init();
431} 428}
432 429
@@ -435,7 +432,7 @@ LLHTTPAssetStorage::~LLHTTPAssetStorage()
435 curl_multi_cleanup(mCurlMultiHandle); 432 curl_multi_cleanup(mCurlMultiHandle);
436 mCurlMultiHandle = NULL; 433 mCurlMultiHandle = NULL;
437 434
438 curl_global_cleanup(); 435 // curl_global_cleanup moved to LLCurl::initClass()
439} 436}
440 437
441// storing data is simpler than getting it, so we just overload the whole method 438// storing data is simpler than getting it, so we just overload the whole method
@@ -451,7 +448,7 @@ void LLHTTPAssetStorage::storeAssetData(
451 bool user_waiting, 448 bool user_waiting,
452 F64 timeout) 449 F64 timeout)
453{ 450{
454 if (mVFS->getExists(uuid, type)) 451 if (mVFS->getExists(uuid, type)) // VFS treats nonexistant and zero-length identically
455 { 452 {
456 LLAssetRequest *req = new LLAssetRequest(uuid, type); 453 LLAssetRequest *req = new LLAssetRequest(uuid, type);
457 req->mUpCallback = callback; 454 req->mUpCallback = callback;
@@ -460,6 +457,19 @@ void LLHTTPAssetStorage::storeAssetData(
460 req->mIsUserWaiting = user_waiting; 457 req->mIsUserWaiting = user_waiting;
461 req->mTimeout = timeout; 458 req->mTimeout = timeout;
462 459
460 // LLAssetStorage metric: Successful Request
461 S32 size = mVFS->getSize(uuid, type);
462 const char *message;
463 if( store_local )
464 {
465 message = "Added to local upload queue";
466 }
467 else
468 {
469 message = "Added to upload queue";
470 }
471 reportMetric( uuid, type, NULL, requesting_agent_id, size, MR_OKAY, __FILE__, __LINE__, message );
472
463 // this will get picked up and transmitted in checkForTimeouts 473 // this will get picked up and transmitted in checkForTimeouts
464 if(store_local) 474 if(store_local)
465 { 475 {
@@ -479,6 +489,8 @@ void LLHTTPAssetStorage::storeAssetData(
479 llwarns << "AssetStorage: attempt to upload non-existent vfile " << uuid << ":" << LLAssetType::lookup(type) << llendl; 489 llwarns << "AssetStorage: attempt to upload non-existent vfile " << uuid << ":" << LLAssetType::lookup(type) << llendl;
480 if (callback) 490 if (callback)
481 { 491 {
492 // LLAssetStorage metric: Zero size VFS
493 reportMetric( uuid, type, NULL, requesting_agent_id, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" );
482 callback(uuid, user_data, LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE); 494 callback(uuid, user_data, LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE);
483 } 495 }
484 } 496 }
@@ -504,13 +516,17 @@ void LLHTTPAssetStorage::storeAssetData(
504 legacy->mUserData = user_data; 516 legacy->mUserData = user_data;
505 517
506 FILE *fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ 518 FILE *fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/
519 S32 size = 0;
507 if (fp) 520 if (fp)
508 { 521 {
509 LLVFile file(mVFS, asset_id, asset_type, LLVFile::WRITE);
510
511 fseek(fp, 0, SEEK_END); 522 fseek(fp, 0, SEEK_END);
512 S32 size = ftell(fp); 523 size = ftell(fp);
513 fseek(fp, 0, SEEK_SET); 524 fseek(fp, 0, SEEK_SET);
525 }
526
527 if( size )
528 {
529 LLVFile file(mVFS, asset_id, asset_type, LLVFile::WRITE);
514 530
515 file.setMaxSize(size); 531 file.setMaxSize(size);
516 532
@@ -528,6 +544,7 @@ void LLHTTPAssetStorage::storeAssetData(
528 LLFile::remove(filename); 544 LLFile::remove(filename);
529 } 545 }
530 546
547 // LLAssetStorage metric: Success not needed; handled in the overloaded method here:
531 storeAssetData( 548 storeAssetData(
532 asset_id, 549 asset_id,
533 asset_type, 550 asset_type,
@@ -540,8 +557,19 @@ void LLHTTPAssetStorage::storeAssetData(
540 user_waiting, 557 user_waiting,
541 timeout); 558 timeout);
542 } 559 }
543 else 560 else // !size
544 { 561 {
562 if( fp )
563 {
564 // LLAssetStorage metric: Zero size
565 reportMetric( asset_id, asset_type, filename, LLUUID::null, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file was zero length" );
566 fclose( fp );
567 }
568 else
569 {
570 // LLAssetStorage metric: Missing File
571 reportMetric( asset_id, asset_type, filename, LLUUID::null, 0, MR_FILE_NONEXIST, __FILE__, __LINE__, "The file didn't exist" );
572 }
545 if (callback) 573 if (callback)
546 { 574 {
547 callback(LLUUID::null, user_data, LL_ERR_CANNOT_OPEN_FILE, LL_EXSTAT_BLOCKED_FILE); 575 callback(LLUUID::null, user_data, LL_ERR_CANNOT_OPEN_FILE, LL_EXSTAT_BLOCKED_FILE);
@@ -827,7 +855,16 @@ void LLHTTPAssetStorage::checkForTimeouts()
827 } 855 }
828 else 856 else
829 { 857 {
830 llinfos << "Requesting PUT " << new_req->mURLBuffer << llendl; 858 // Get the uncompressed file size.
859 LLVFile file(mVFS,new_req->getUUID(),new_req->getType());
860 S32 size = file.getSize();
861 llinfos << "Requesting PUT " << new_req->mURLBuffer << ", asset size: " << size << " bytes" << llendl;
862 if (size == 0)
863 {
864 llwarns << "Rejecting zero size PUT request!" << llendl;
865 new_req->cleanupCurlHandle();
866 deletePendingRequest(RT_UPLOAD, new_req->getType(), new_req->getUUID());
867 }
831 } 868 }
832 // Pending upload will have been flagged by the request 869 // Pending upload will have been flagged by the request
833 } 870 }
@@ -867,8 +904,19 @@ void LLHTTPAssetStorage::checkForTimeouts()
867 } 904 }
868 else 905 else
869 { 906 {
907 // Get the uncompressed file size.
908 S32 size = file.getSize();
909
870 llinfos << "TAT: LLHTTPAssetStorage::checkForTimeouts() : pending local!" 910 llinfos << "TAT: LLHTTPAssetStorage::checkForTimeouts() : pending local!"
871 << " Requesting PUT " << new_req->mURLBuffer << llendl; 911 << " Requesting PUT " << new_req->mURLBuffer << ", asset size: " << size << " bytes" << llendl;
912 if (size == 0)
913 {
914
915 llwarns << "Rejecting zero size PUT request!" << llendl;
916 new_req->cleanupCurlHandle();
917 deletePendingRequest(RT_UPLOAD, new_req->getType(), new_req->getUUID());
918 }
919
872 } 920 }
873 // Pending upload will have been flagged by the request 921 // Pending upload will have been flagged by the request
874 } 922 }
@@ -1403,5 +1451,3 @@ void LLHTTPAssetStorage::clearTempAssetData()
1403 llinfos << "TAT: Clearing temp asset data map" << llendl; 1451 llinfos << "TAT: Clearing temp asset data map" << llendl;
1404 mTempAssets.clear(); 1452 mTempAssets.clear();
1405} 1453}
1406
1407