summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2016-03-17 13:14:21 -0700
committerRider Linden <rider@lindenlab.com>2016-03-17 13:14:21 -0700
commitb8c1976460374e743743728ef49b38ad52c453a4 (patch)
tree4f340d954ae3552d4dbb87b389d15d98d66eba51 /indra/llmessage
parent7a0fb4fece5a92627caa08622e9584a903a3fa1d (diff)
parent4aae7b51616c0963af4668442bdb5bfaba8c5044 (diff)
Merge
Diffstat (limited to 'indra/llmessage')
-rwxr-xr-xindra/llmessage/llassetstorage.cpp142
-rwxr-xr-xindra/llmessage/llassetstorage.h112
-rwxr-xr-xindra/llmessage/lltransfertargetvfile.cpp38
-rwxr-xr-xindra/llmessage/lltransfertargetvfile.h6
4 files changed, 156 insertions, 142 deletions
diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp
index 0d8aaf2269..bcf4e52b8f 100755
--- a/indra/llmessage/llassetstorage.cpp
+++ b/indra/llmessage/llassetstorage.cpp
@@ -158,28 +158,49 @@ void LLAssetInfo::setFromNameValue( const LLNameValue& nv )
}
///----------------------------------------------------------------------------
+/// LLBaseDownloadRequest
+///----------------------------------------------------------------------------
+
+LLBaseDownloadRequest::LLBaseDownloadRequest(const LLUUID &uuid, const LLAssetType::EType type)
+: mUUID(uuid),
+mType(type),
+mDownCallback(NULL),
+mUserData(NULL),
+mHost(),
+mIsTemp(FALSE),
+mIsPriority(FALSE),
+mDataSentInFirstPacket(FALSE),
+mDataIsInVFS(FALSE)
+{
+ // Need to guarantee that this time is up to date, we may be creating a circuit even though we haven't been
+ // running a message system loop.
+ mTime = LLMessageSystem::getMessageTimeSeconds(TRUE);
+}
+
+// virtual
+LLBaseDownloadRequest::~LLBaseDownloadRequest()
+{
+}
+
+// virtual
+LLBaseDownloadRequest* LLBaseDownloadRequest::getCopy()
+{
+ return new LLBaseDownloadRequest(*this);
+}
+
+
+///----------------------------------------------------------------------------
/// LLAssetRequest
///----------------------------------------------------------------------------
LLAssetRequest::LLAssetRequest(const LLUUID &uuid, const LLAssetType::EType type)
-: mUUID(uuid),
- mType(type),
- mDownCallback( NULL ),
+: LLBaseDownloadRequest(uuid, type),
mUpCallback( NULL ),
mInfoCallback( NULL ),
- mUserData( NULL ),
- mHost(),
- mIsTemp( FALSE ),
mIsLocal(FALSE),
mIsUserWaiting(FALSE),
- mTimeout(LL_ASSET_STORAGE_TIMEOUT),
- mIsPriority(FALSE),
- mDataSentInFirstPacket(FALSE),
- mDataIsInVFS( FALSE )
+ mTimeout(LL_ASSET_STORAGE_TIMEOUT)
{
- // Need to guarantee that this time is up to date, we may be creating a circuit even though we haven't been
- // running a message system loop.
- mTime = LLMessageSystem::getMessageTimeSeconds(TRUE);
}
// virtual
@@ -217,56 +238,51 @@ LLSD LLAssetRequest::getFullDetails() const
return sd;
}
+LLBaseDownloadRequest* LLAssetRequest::getCopy()
+{
+ return new LLAssetRequest(*this);
+}
+
///----------------------------------------------------------------------------
/// LLInvItemRequest
///----------------------------------------------------------------------------
LLInvItemRequest::LLInvItemRequest(const LLUUID &uuid, const LLAssetType::EType type)
-: mUUID(uuid),
- mType(type),
- mDownCallback( NULL ),
- mUserData( NULL ),
- mHost(),
- mIsTemp( FALSE ),
- mIsPriority(FALSE),
- mDataSentInFirstPacket(FALSE),
- mDataIsInVFS( FALSE )
+: LLBaseDownloadRequest(uuid, type)
{
- // Need to guarantee that this time is up to date, we may be creating a circuit even though we haven't been
- // running a message system loop.
- mTime = LLMessageSystem::getMessageTimeSeconds(TRUE);
}
+// virtual
LLInvItemRequest::~LLInvItemRequest()
{
}
+LLBaseDownloadRequest* LLInvItemRequest::getCopy()
+{
+ return new LLInvItemRequest(*this);
+}
+
///----------------------------------------------------------------------------
/// LLEstateAssetRequest
///----------------------------------------------------------------------------
LLEstateAssetRequest::LLEstateAssetRequest(const LLUUID &uuid, const LLAssetType::EType atype,
EstateAssetType etype)
-: mUUID(uuid),
- mAType(atype),
- mEstateAssetType(etype),
- mDownCallback( NULL ),
- mUserData( NULL ),
- mHost(),
- mIsTemp( FALSE ),
- mIsPriority(FALSE),
- mDataSentInFirstPacket(FALSE),
- mDataIsInVFS( FALSE )
-{
- // Need to guarantee that this time is up to date, we may be creating a circuit even though we haven't been
- // running a message system loop.
- mTime = LLMessageSystem::getMessageTimeSeconds(TRUE);
+: LLBaseDownloadRequest(uuid, atype),
+ mEstateAssetType(etype)
+{
}
+// Virtual
LLEstateAssetRequest::~LLEstateAssetRequest()
{
}
+LLBaseDownloadRequest* LLEstateAssetRequest::getCopy()
+{
+ return new LLEstateAssetRequest(*this);
+}
+
///----------------------------------------------------------------------------
/// LLAssetStorage
@@ -565,7 +581,7 @@ void LLAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType at
// Set our destination file, and the completion callback.
LLTransferTargetParamsVFile tpvf;
tpvf.setAsset(uuid, atype);
- tpvf.setCallback(downloadCompleteCallback, req);
+ tpvf.setCallback(downloadCompleteCallback, *req);
//LL_INFOS() << "Starting transfer for " << uuid << LL_ENDL;
LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(mUpstreamHost, LLTCT_ASSET);
@@ -589,7 +605,7 @@ void LLAssetStorage::downloadCompleteCallback(
S32 result,
const LLUUID& file_id,
LLAssetType::EType file_type,
- void* user_data, LLExtStat ext_status)
+ LLBaseDownloadRequest* user_data, LLExtStat ext_status)
{
LL_DEBUGS("AssetStorage") << "ASSET_TRACE asset " << file_id << " downloadCompleteCallback" << LL_ENDL;
@@ -608,36 +624,40 @@ void LLAssetStorage::downloadCompleteCallback(
return;
}
+ LLUUID callback_id;
+ LLAssetType::EType callback_type;
+
// Inefficient since we're doing a find through a list that may have thousands of elements.
// This is due for refactoring; we will probably change mPendingDownloads into a set.
request_list_t::iterator download_iter = std::find(gAssetStorage->mPendingDownloads.begin(),
gAssetStorage->mPendingDownloads.end(),
req);
- // If the LLAssetRequest doesn't exist in the downloads queue, then it either has already been deleted
- // by _cleanupRequests, or it's a transfer.
+
if (download_iter != gAssetStorage->mPendingDownloads.end())
{
- req->setUUID(file_id);
- req->setType(file_type);
+ callback_id = file_id;
+ callback_type = file_type;
+ }
+ else
+ {
+ // either has already been deleted by _cleanupRequests or it's a transfer.
+ callback_id = req->getUUID();
+ callback_type = req->getType();
}
if (LL_ERR_NOERR == result)
{
// we might have gotten a zero-size file
- LLVFile vfile(gAssetStorage->mVFS, req->getUUID(), req->getType());
+ LLVFile vfile(gAssetStorage->mVFS, callback_id, callback_type);
if (vfile.getSize() <= 0)
{
- LL_WARNS() << "downloadCompleteCallback has non-existent or zero-size asset " << req->getUUID() << LL_ENDL;
+ LL_WARNS() << "downloadCompleteCallback has non-existent or zero-size asset " << callback_id << LL_ENDL;
result = LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE;
vfile.remove();
}
}
- // we will be deleting elements of mPendingDownloads which req might be part of, save id and type for reference
- LLUUID callback_id = req->getUUID();
- LLAssetType::EType callback_type = req->getType();
-
// find and callback ALL pending requests for this UUID
// SJB: We process the callbacks in reverse order, I do not know if this is important,
// but I didn't want to mess with it.
@@ -731,10 +751,10 @@ void LLAssetStorage::getEstateAsset(const LLHost &object_sim, const LLUUID &agen
if (source_host.isOk())
{
// stash the callback info so we can find it after we get the response message
- LLEstateAssetRequest *req = new LLEstateAssetRequest(asset_id, atype, etype);
- req->mDownCallback = callback;
- req->mUserData = user_data;
- req->mIsPriority = is_priority;
+ LLEstateAssetRequest req(asset_id, atype, etype);
+ req.mDownCallback = callback;
+ req.mUserData = user_data;
+ req.mIsPriority = is_priority;
// send request message to our upstream data provider
// Create a new asset transfer.
@@ -768,7 +788,7 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback(
S32 result,
const LLUUID& file_id,
LLAssetType::EType file_type,
- void* user_data,
+ LLBaseDownloadRequest* user_data,
LLExtStat ext_status)
{
LLEstateAssetRequest *req = (LLEstateAssetRequest*)user_data;
@@ -875,10 +895,10 @@ void LLAssetStorage::getInvItemAsset(const LLHost &object_sim, const LLUUID &age
if (source_host.isOk())
{
// stash the callback info so we can find it after we get the response message
- LLInvItemRequest *req = new LLInvItemRequest(asset_id, atype);
- req->mDownCallback = callback;
- req->mUserData = user_data;
- req->mIsPriority = is_priority;
+ LLInvItemRequest req(asset_id, atype);
+ req.mDownCallback = callback;
+ req.mUserData = user_data;
+ req.mIsPriority = is_priority;
// send request message to our upstream data provider
// Create a new asset transfer.
@@ -916,7 +936,7 @@ void LLAssetStorage::downloadInvItemCompleteCallback(
S32 result,
const LLUUID& file_id,
LLAssetType::EType file_type,
- void* user_data,
+ LLBaseDownloadRequest* user_data,
LLExtStat ext_status)
{
LLInvItemRequest *req = (LLInvItemRequest*)user_data;
diff --git a/indra/llmessage/llassetstorage.h b/indra/llmessage/llassetstorage.h
index c3d31ba84c..4be677a4b0 100755
--- a/indra/llmessage/llassetstorage.h
+++ b/indra/llmessage/llassetstorage.h
@@ -91,38 +91,52 @@ public:
};
-class LLAssetRequest
+class LLBaseDownloadRequest
{
public:
- LLAssetRequest(const LLUUID &uuid, const LLAssetType::EType at);
- virtual ~LLAssetRequest();
-
- LLUUID getUUID() const { return mUUID; }
- LLAssetType::EType getType() const { return mType; }
+ LLBaseDownloadRequest(const LLUUID &uuid, const LLAssetType::EType at);
+ virtual ~LLBaseDownloadRequest();
+
+ LLUUID getUUID() const { return mUUID; }
+ LLAssetType::EType getType() const { return mType; }
+
+ void setUUID(const LLUUID& id) { mUUID = id; }
+ void setType(LLAssetType::EType type) { mType = type; }
- void setUUID(const LLUUID& id) { mUUID = id; }
- void setType(LLAssetType::EType type) { mType = type; }
- void setTimeout (F64Seconds timeout) { mTimeout = timeout; }
+ virtual LLBaseDownloadRequest* getCopy();
protected:
- LLUUID mUUID;
- LLAssetType::EType mType;
+ LLUUID mUUID;
+ LLAssetType::EType mType;
+
+public:
+ void(*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat);
+
+ void *mUserData;
+ LLHost mHost;
+ BOOL mIsTemp;
+ F64Seconds mTime; // Message system time
+ BOOL mIsPriority;
+ BOOL mDataSentInFirstPacket;
+ BOOL mDataIsInVFS;
+};
+class LLAssetRequest : public LLBaseDownloadRequest
+{
public:
- void (*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat);
+ LLAssetRequest(const LLUUID &uuid, const LLAssetType::EType at);
+ virtual ~LLAssetRequest();
+
+ void setTimeout(F64Seconds timeout) { mTimeout = timeout; }
+
+ virtual LLBaseDownloadRequest* getCopy();
+
void (*mUpCallback)(const LLUUID&, void *, S32, LLExtStat);
void (*mInfoCallback)(LLAssetInfo *, void *, S32);
- void *mUserData;
- LLHost mHost;
- BOOL mIsTemp;
BOOL mIsLocal;
BOOL mIsUserWaiting; // We don't want to try forever if a user is waiting for a result.
- F64Seconds mTime; // Message system time
F64Seconds mTimeout; // Amount of time before timing out.
- BOOL mIsPriority;
- BOOL mDataSentInFirstPacket;
- BOOL mDataIsInVFS;
LLUUID mRequestingAgentID; // Only valid for uploads from an agent
virtual LLSD getTerseDetails() const;
@@ -140,63 +154,27 @@ struct ll_asset_request_equal : public std::equal_to<T>
};
-class LLInvItemRequest
+class LLInvItemRequest : public LLBaseDownloadRequest
{
public:
- LLInvItemRequest(const LLUUID &uuid, const LLAssetType::EType at);
- virtual ~LLInvItemRequest();
-
- LLUUID getUUID() const { return mUUID; }
- LLAssetType::EType getType() const { return mType; }
-
- void setUUID(const LLUUID& id) { mUUID = id; }
- void setType(LLAssetType::EType type) { mType = type; }
-
-protected:
- LLUUID mUUID;
- LLAssetType::EType mType;
-
-public:
- void (*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat);
-
- void *mUserData;
- LLHost mHost;
- BOOL mIsTemp;
- F64Seconds mTime; // Message system time
- BOOL mIsPriority;
- BOOL mDataSentInFirstPacket;
- BOOL mDataIsInVFS;
+ LLInvItemRequest(const LLUUID &uuid, const LLAssetType::EType at);
+ virtual ~LLInvItemRequest();
+ virtual LLBaseDownloadRequest* getCopy();
};
-class LLEstateAssetRequest
+class LLEstateAssetRequest : public LLBaseDownloadRequest
{
public:
- LLEstateAssetRequest(const LLUUID &uuid, const LLAssetType::EType at, EstateAssetType et);
- virtual ~LLEstateAssetRequest();
+ LLEstateAssetRequest(const LLUUID &uuid, const LLAssetType::EType at, EstateAssetType et);
+ virtual ~LLEstateAssetRequest();
- LLUUID getUUID() const { return mUUID; }
- LLAssetType::EType getAType() const { return mAType; }
+ LLAssetType::EType getAType() const { return mType; }
- void setUUID(const LLUUID& id) { mUUID = id; }
- void setType(LLAssetType::EType type) { mAType = type; }
+ virtual LLBaseDownloadRequest* getCopy();
protected:
- LLUUID mUUID;
- LLAssetType::EType mAType;
EstateAssetType mEstateAssetType;
-
-public:
- void (*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat);
-
- void *mUserData;
- LLHost mHost;
- BOOL mIsTemp;
- F64Seconds mTime; // Message system time
- BOOL mIsPriority;
- BOOL mDataSentInFirstPacket;
- BOOL mDataIsInVFS;
-
};
@@ -368,17 +346,17 @@ public:
S32 result,
const LLUUID& file_id,
LLAssetType::EType file_type,
- void* user_data, LLExtStat ext_status);
+ LLBaseDownloadRequest* user_data, LLExtStat ext_status);
static void downloadEstateAssetCompleteCallback(
S32 result,
const LLUUID& file_id,
LLAssetType::EType file_type,
- void* user_data, LLExtStat ext_status);
+ LLBaseDownloadRequest* user_data, LLExtStat ext_status);
static void downloadInvItemCompleteCallback(
S32 result,
const LLUUID& file_id,
LLAssetType::EType file_type,
- void* user_data, LLExtStat ext_status);
+ LLBaseDownloadRequest* user_data, LLExtStat ext_status);
// upload process callbacks
static void uploadCompleteCallback(const LLUUID&, void *user_data, S32 result, LLExtStat ext_status);
diff --git a/indra/llmessage/lltransfertargetvfile.cpp b/indra/llmessage/lltransfertargetvfile.cpp
index 3c234b9726..a572c68a7f 100755
--- a/indra/llmessage/lltransfertargetvfile.cpp
+++ b/indra/llmessage/lltransfertargetvfile.cpp
@@ -42,7 +42,7 @@ LLTransferTargetParamsVFile::LLTransferTargetParamsVFile() :
LLTransferTargetParams(LLTTT_VFILE),
mAssetType(LLAssetType::AT_NONE),
mCompleteCallback(NULL),
- mUserDatap(NULL),
+ mRequestDatap(NULL),
mErrCode(0)
{
}
@@ -55,10 +55,14 @@ void LLTransferTargetParamsVFile::setAsset(
mAssetType = asset_type;
}
-void LLTransferTargetParamsVFile::setCallback(LLTTVFCompleteCallback cb, void *user_data)
+void LLTransferTargetParamsVFile::setCallback(LLTTVFCompleteCallback cb, LLBaseDownloadRequest& request)
{
mCompleteCallback = cb;
- mUserDatap = user_data;
+ if (mRequestDatap)
+ {
+ delete mRequestDatap;
+ }
+ mRequestDatap = request.getCopy();
}
bool LLTransferTargetParamsVFile::unpackParams(LLDataPacker& dp)
@@ -98,6 +102,12 @@ LLTransferTargetVFile::LLTransferTargetVFile(
LLTransferTargetVFile::~LLTransferTargetVFile()
{
+ if (mParams.mRequestDatap)
+ {
+ // TODO: Consider doing it in LLTransferTargetParamsVFile's destructor
+ delete mParams.mRequestDatap;
+ mParams.mRequestDatap = NULL;
+ }
}
@@ -208,12 +218,18 @@ void LLTransferTargetVFile::completionCallback(const LLTSCode status)
err_code = LL_ERR_ASSET_REQUEST_FAILED;
break;
}
- if (mParams.mCompleteCallback)
- {
- mParams.mCompleteCallback(err_code,
- mParams.getAssetID(),
- mParams.getAssetType(),
- mParams.mUserDatap,
- LL_EXSTAT_NONE);
- }
+
+ if (mParams.mRequestDatap)
+ {
+ if (mParams.mCompleteCallback)
+ {
+ mParams.mCompleteCallback(err_code,
+ mParams.getAssetID(),
+ mParams.getAssetType(),
+ mParams.mRequestDatap,
+ LL_EXSTAT_NONE);
+ }
+ delete mParams.mRequestDatap;
+ mParams.mRequestDatap = NULL;
+ }
}
diff --git a/indra/llmessage/lltransfertargetvfile.h b/indra/llmessage/lltransfertargetvfile.h
index 23a65e4bb2..c819c1e2f2 100755
--- a/indra/llmessage/lltransfertargetvfile.h
+++ b/indra/llmessage/lltransfertargetvfile.h
@@ -39,7 +39,7 @@ typedef void (*LLTTVFCompleteCallback)(
S32 status,
const LLUUID& file_id,
LLAssetType::EType file_type,
- void* user_data, LLExtStat ext_status );
+ LLBaseDownloadRequest* user_data, LLExtStat ext_status );
class LLTransferTargetParamsVFile : public LLTransferTargetParams
{
@@ -47,7 +47,7 @@ public:
LLTransferTargetParamsVFile();
void setAsset(const LLUUID& asset_id, LLAssetType::EType asset_type);
- void setCallback(LLTTVFCompleteCallback cb, void* user_data);
+ void setCallback(LLTTVFCompleteCallback cb, LLBaseDownloadRequest& request);
LLUUID getAssetID() const { return mAssetID; }
LLAssetType::EType getAssetType() const { return mAssetType; }
@@ -60,7 +60,7 @@ protected:
LLAssetType::EType mAssetType;
LLTTVFCompleteCallback mCompleteCallback;
- void* mUserDatap;
+ LLBaseDownloadRequest* mRequestDatap;
S32 mErrCode;
};