aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llhttpassetstorage.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:54 -0500
committerJacek Antonelli2008-08-15 23:44:54 -0500
commitb2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch)
tree3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llmessage/llhttpassetstorage.cpp
parentSecond Life viewer sources 1.14.0.1 (diff)
downloadmeta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/llmessage/llhttpassetstorage.cpp')
-rw-r--r--linden/indra/llmessage/llhttpassetstorage.cpp51
1 files changed, 31 insertions, 20 deletions
diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp
index 6c57499..8e328ce 100644
--- a/linden/indra/llmessage/llhttpassetstorage.cpp
+++ b/linden/indra/llmessage/llhttpassetstorage.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2003-2007, Linden Research, Inc. 6 * Copyright (c) 2003-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -38,7 +39,7 @@
38 39
39#include "zlib/zlib.h" 40#include "zlib/zlib.h"
40 41
41const U32 MAX_RUNNING_REQUESTS = 4; 42const U32 MAX_RUNNING_REQUESTS = 1;
42const F32 MAX_PROCESSING_TIME = 0.005f; 43const F32 MAX_PROCESSING_TIME = 0.005f;
43const S32 CURL_XFER_BUFFER_SIZE = 65536; 44const S32 CURL_XFER_BUFFER_SIZE = 65536;
44// Try for 30 minutes for now. 45// Try for 30 minutes for now.
@@ -77,6 +78,7 @@ public:
77 virtual ~LLHTTPAssetRequest(); 78 virtual ~LLHTTPAssetRequest();
78 79
79 void setupCurlHandle(); 80 void setupCurlHandle();
81 void cleanupCurlHandle();
80 82
81 void prepareCompressedUpload(); 83 void prepareCompressedUpload();
82 void finishCompressedUpload(); 84 void finishCompressedUpload();
@@ -140,16 +142,7 @@ LLHTTPAssetRequest::~LLHTTPAssetRequest()
140 if (mCurlHandle) 142 if (mCurlHandle)
141 { 143 {
142 curl_multi_remove_handle(mCurlMultiHandle, mCurlHandle); 144 curl_multi_remove_handle(mCurlMultiHandle, mCurlHandle);
143 curl_easy_cleanup(mCurlHandle); 145 cleanupCurlHandle();
144 if (mAssetStoragep)
145 {
146 // Terminating a request. Thus upload or download is no longer pending.
147 mAssetStoragep->removeRunningRequest(mRequestType, this);
148 }
149 else
150 {
151 llerrs << "LLHTTPAssetRequest::~LLHTTPAssetRequest - No asset storage associated with this request!" << llendl;
152 }
153 } 146 }
154 if (mHTTPHeaders) 147 if (mHTTPHeaders)
155 { 148 {
@@ -274,6 +267,21 @@ void LLHTTPAssetRequest::setupCurlHandle()
274 } 267 }
275} 268}
276 269
270void LLHTTPAssetRequest::cleanupCurlHandle()
271{
272 curl_easy_cleanup(mCurlHandle);
273 if (mAssetStoragep)
274 {
275 // Terminating a request. Thus upload or download is no longer pending.
276 mAssetStoragep->removeRunningRequest(mRequestType, this);
277 }
278 else
279 {
280 llerrs << "LLHTTPAssetRequest::~LLHTTPAssetRequest - No asset storage associated with this request!" << llendl;
281 }
282 mCurlHandle = NULL;
283}
284
277void LLHTTPAssetRequest::prepareCompressedUpload() 285void LLHTTPAssetRequest::prepareCompressedUpload()
278{ 286{
279 mZStream.next_in = Z_NULL; 287 mZStream.next_in = Z_NULL;
@@ -682,7 +690,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
682{ 690{
683 CURLMcode mcode; 691 CURLMcode mcode;
684 LLAssetRequest *req; 692 LLAssetRequest *req;
685 while (req = findNextRequest(mPendingDownloads, mRunningDownloads)) 693 while ( (req = findNextRequest(mPendingDownloads, mRunningDownloads)) )
686 { 694 {
687 // Setup this curl download request 695 // Setup this curl download request
688 // We need to generate a new request here 696 // We need to generate a new request here
@@ -691,7 +699,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
691 char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ 699 char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
692 req->getUUID().toString(uuid_str); 700 req->getUUID().toString(uuid_str);
693 std::string base_url = getBaseURL(req->getUUID(), req->getType()); 701 std::string base_url = getBaseURL(req->getUUID(), req->getType());
694 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ 702 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */
695 703
696 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), 704 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(),
697 req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle); 705 req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle);
@@ -708,7 +716,8 @@ void LLHTTPAssetStorage::checkForTimeouts()
708 { 716 {
709 // Failure. Deleting the pending request will remove it from the running 717 // Failure. Deleting the pending request will remove it from the running
710 // queue, and push it to the end of the pending queue. 718 // queue, and push it to the end of the pending queue.
711 deletePendingRequest(RT_DOWNLOAD, req->getType(), req->getUUID()); 719 new_req->cleanupCurlHandle();
720 deletePendingRequest(RT_DOWNLOAD, new_req->getType(), new_req->getUUID());
712 break; 721 break;
713 } 722 }
714 else 723 else
@@ -717,7 +726,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
717 } 726 }
718 } 727 }
719 728
720 while (req = findNextRequest(mPendingUploads, mRunningUploads)) 729 while ( (req = findNextRequest(mPendingUploads, mRunningUploads)) )
721 { 730 {
722 // setup this curl upload request 731 // setup this curl upload request
723 732
@@ -726,7 +735,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
726 char tmp_url[MAX_STRING];/*Flawfinder: ignore*/ 735 char tmp_url[MAX_STRING];/*Flawfinder: ignore*/
727 char uuid_str[UUID_STR_LENGTH];/*Flawfinder: ignore*/ 736 char uuid_str[UUID_STR_LENGTH];/*Flawfinder: ignore*/
728 req->getUUID().toString(uuid_str); 737 req->getUUID().toString(uuid_str);
729 snprintf(tmp_url, sizeof(tmp_url), /*Flawfinder: ignore*/ 738 snprintf(tmp_url, sizeof(tmp_url), /* Flawfinder: ignore */
730 do_compress ? "%s/%s.%s.gz" : "%s/%s.%s", 739 do_compress ? "%s/%s.%s.gz" : "%s/%s.%s",
731 mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); 740 mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType()));
732 741
@@ -761,7 +770,8 @@ void LLHTTPAssetStorage::checkForTimeouts()
761 { 770 {
762 // Failure. Deleting the pending request will remove it from the running 771 // Failure. Deleting the pending request will remove it from the running
763 // queue, and push it to the end of the pending queue. 772 // queue, and push it to the end of the pending queue.
764 deletePendingRequest(RT_UPLOAD, req->getType(), req->getUUID()); 773 new_req->cleanupCurlHandle();
774 deletePendingRequest(RT_UPLOAD, new_req->getType(), new_req->getUUID());
765 break; 775 break;
766 } 776 }
767 else 777 else
@@ -771,7 +781,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
771 // Pending upload will have been flagged by the request 781 // Pending upload will have been flagged by the request
772 } 782 }
773 783
774 while (req = findNextRequest(mPendingLocalUploads, mRunningLocalUploads)) 784 while ( (req = findNextRequest(mPendingLocalUploads, mRunningLocalUploads)) )
775 { 785 {
776 // setup this curl upload request 786 // setup this curl upload request
777 LLVFile file(mVFS, req->getUUID(), req->getType()); 787 LLVFile file(mVFS, req->getUUID(), req->getType());
@@ -781,7 +791,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
781 req->getUUID().toString(uuid_str); 791 req->getUUID().toString(uuid_str);
782 792
783 // KLW - All temporary uploads are saved locally "http://localhost:12041/asset" 793 // KLW - All temporary uploads are saved locally "http://localhost:12041/asset"
784 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ 794 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */
785 795
786 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), 796 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(),
787 req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle); 797 req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle);
@@ -800,7 +810,8 @@ void LLHTTPAssetStorage::checkForTimeouts()
800 { 810 {
801 // Failure. Deleting the pending request will remove it from the running 811 // Failure. Deleting the pending request will remove it from the running
802 // queue, and push it to the end of the pending queue. 812 // queue, and push it to the end of the pending queue.
803 deletePendingRequest(RT_LOCALUPLOAD, req->getType(), req->getUUID()); 813 new_req->cleanupCurlHandle();
814 deletePendingRequest(RT_LOCALUPLOAD, new_req->getType(), new_req->getUUID());
804 break; 815 break;
805 } 816 }
806 else 817 else