diff options
Diffstat (limited to 'linden/indra/llmessage/llassetstorage.cpp')
-rw-r--r-- | linden/indra/llmessage/llassetstorage.cpp | 127 |
1 files changed, 93 insertions, 34 deletions
diff --git a/linden/indra/llmessage/llassetstorage.cpp b/linden/indra/llmessage/llassetstorage.cpp index a6077e5..fa14a2b 100644 --- a/linden/indra/llmessage/llassetstorage.cpp +++ b/linden/indra/llmessage/llassetstorage.cpp | |||
@@ -42,6 +42,7 @@ | |||
42 | #include "llstring.h" | 42 | #include "llstring.h" |
43 | #include "lldir.h" | 43 | #include "lldir.h" |
44 | #include "llsd.h" | 44 | #include "llsd.h" |
45 | #include "llframetimer.h" | ||
45 | 46 | ||
46 | // this library includes | 47 | // this library includes |
47 | #include "message.h" | 48 | #include "message.h" |
@@ -58,7 +59,10 @@ | |||
58 | LLAssetStorage *gAssetStorage = NULL; | 59 | LLAssetStorage *gAssetStorage = NULL; |
59 | LLMetrics *LLAssetStorage::metric_recipient = NULL; | 60 | LLMetrics *LLAssetStorage::metric_recipient = NULL; |
60 | 61 | ||
61 | const LLUUID CATEGORIZE_LOST_AND_FOUND_ID("00000000-0000-0000-0000-000000000010"); | 62 | const LLUUID CATEGORIZE_LOST_AND_FOUND_ID(std::string("00000000-0000-0000-0000-000000000010")); |
63 | |||
64 | const U64 TOXIC_ASSET_LIFETIME = (120 * 1000000); // microseconds | ||
65 | |||
62 | 66 | ||
63 | ///---------------------------------------------------------------------------- | 67 | ///---------------------------------------------------------------------------- |
64 | /// LLAssetInfo | 68 | /// LLAssetInfo |
@@ -133,20 +137,20 @@ void LLAssetInfo::setFromNameValue( const LLNameValue& nv ) | |||
133 | str.assign( nv.mName ); | 137 | str.assign( nv.mName ); |
134 | pos1 = str.find('|'); | 138 | pos1 = str.find('|'); |
135 | buf.assign( str, 0, pos1++ ); | 139 | buf.assign( str, 0, pos1++ ); |
136 | mType = LLAssetType::lookup( buf.c_str() ); | 140 | mType = LLAssetType::lookup( buf ); |
137 | buf.assign( str, pos1, std::string::npos ); | 141 | buf.assign( str, pos1, std::string::npos ); |
138 | mUuid.set( buf.c_str() ); | 142 | mUuid.set( buf ); |
139 | 143 | ||
140 | // convert the value to useful information | 144 | // convert the value to useful information |
141 | str.assign( nv.getAsset() ); | 145 | str.assign( nv.getAsset() ); |
142 | pos1 = str.find('|'); | 146 | pos1 = str.find('|'); |
143 | buf.assign( str, 0, pos1++ ); | 147 | buf.assign( str, 0, pos1++ ); |
144 | mCreatorID.set( buf.c_str() ); | 148 | mCreatorID.set( buf ); |
145 | pos2 = str.find( '|', pos1 ); | 149 | pos2 = str.find( '|', pos1 ); |
146 | buf.assign( str, pos1, (pos2++) - pos1 ); | 150 | buf.assign( str, pos1, (pos2++) - pos1 ); |
147 | setName( buf.c_str() ); | 151 | setName( buf ); |
148 | buf.assign( str, pos2, std::string::npos ); | 152 | buf.assign( str, pos2, std::string::npos ); |
149 | setDescription( buf.c_str() ); | 153 | setDescription( buf ); |
150 | llinfos << "uuid: " << mUuid << llendl; | 154 | llinfos << "uuid: " << mUuid << llendl; |
151 | llinfos << "creator: " << mCreatorID << llendl; | 155 | llinfos << "creator: " << mCreatorID << llendl; |
152 | } | 156 | } |
@@ -314,6 +318,9 @@ LLAssetStorage::~LLAssetStorage() | |||
314 | // unregister our callbacks with the message system | 318 | // unregister our callbacks with the message system |
315 | gMessageSystem->setHandlerFuncFast(_PREHASH_AssetUploadComplete, NULL, NULL); | 319 | gMessageSystem->setHandlerFuncFast(_PREHASH_AssetUploadComplete, NULL, NULL); |
316 | } | 320 | } |
321 | |||
322 | // Clear the toxic asset map | ||
323 | mToxicAssetMap.clear(); | ||
317 | } | 324 | } |
318 | 325 | ||
319 | void LLAssetStorage::setUpstream(const LLHost &upstream_host) | 326 | void LLAssetStorage::setUpstream(const LLHost &upstream_host) |
@@ -1231,16 +1238,20 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo | |||
1231 | void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 status, LLExtStat ext_status) | 1238 | void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 status, LLExtStat ext_status) |
1232 | { | 1239 | { |
1233 | LLLegacyAssetRequest *legacy = (LLLegacyAssetRequest *)user_data; | 1240 | LLLegacyAssetRequest *legacy = (LLLegacyAssetRequest *)user_data; |
1234 | char filename[LL_MAX_PATH] = ""; /* Flawfinder: ignore */ | 1241 | std::string filename; |
1242 | |||
1243 | // Check if the asset is marked toxic, and don't load bad stuff | ||
1244 | BOOL toxic = gAssetStorage->isAssetToxic( uuid ); | ||
1235 | 1245 | ||
1236 | if (! status) | 1246 | if ( !status |
1247 | && !toxic ) | ||
1237 | { | 1248 | { |
1238 | LLVFile file(vfs, uuid, type); | 1249 | LLVFile file(vfs, uuid, type); |
1239 | 1250 | ||
1240 | char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ | 1251 | std::string uuid_str; |
1241 | 1252 | ||
1242 | uuid.toString(uuid_str); | 1253 | uuid.toString(uuid_str); |
1243 | snprintf(filename,sizeof(filename),"%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ | 1254 | filename = llformat("%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); |
1244 | 1255 | ||
1245 | LLFILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ | 1256 | LLFILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ |
1246 | if (fp) | 1257 | if (fp) |
@@ -1264,7 +1275,7 @@ void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAss | |||
1264 | } | 1275 | } |
1265 | } | 1276 | } |
1266 | 1277 | ||
1267 | legacy->mDownCallback(filename, uuid, legacy->mUserData, status, ext_status); | 1278 | legacy->mDownCallback(filename.c_str(), uuid, legacy->mUserData, status, ext_status); |
1268 | delete legacy; | 1279 | delete legacy; |
1269 | } | 1280 | } |
1270 | 1281 | ||
@@ -1283,7 +1294,7 @@ void LLAssetStorage::storeAssetData( | |||
1283 | { | 1294 | { |
1284 | llwarns << "storeAssetData: wrong version called" << llendl; | 1295 | llwarns << "storeAssetData: wrong version called" << llendl; |
1285 | // LLAssetStorage metric: Virtual base call | 1296 | // LLAssetStorage metric: Virtual base call |
1286 | reportMetric( LLUUID::null, asset_type, NULL, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 1" ); | 1297 | reportMetric( LLUUID::null, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 1" ); |
1287 | } | 1298 | } |
1288 | 1299 | ||
1289 | // virtual | 1300 | // virtual |
@@ -1302,13 +1313,13 @@ void LLAssetStorage::storeAssetData( | |||
1302 | { | 1313 | { |
1303 | llwarns << "storeAssetData: wrong version called" << llendl; | 1314 | llwarns << "storeAssetData: wrong version called" << llendl; |
1304 | // LLAssetStorage metric: Virtual base call | 1315 | // LLAssetStorage metric: Virtual base call |
1305 | reportMetric( asset_id, asset_type, NULL, requesting_agent_id, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 2" ); | 1316 | reportMetric( asset_id, asset_type, LLStringUtil::null, requesting_agent_id, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 2" ); |
1306 | } | 1317 | } |
1307 | 1318 | ||
1308 | // virtual | 1319 | // virtual |
1309 | // this does nothing, viewer and sim both override this. | 1320 | // this does nothing, viewer and sim both override this. |
1310 | void LLAssetStorage::storeAssetData( | 1321 | void LLAssetStorage::storeAssetData( |
1311 | const char* filename, | 1322 | const std::string& filename, |
1312 | const LLUUID& asset_id, | 1323 | const LLUUID& asset_id, |
1313 | LLAssetType::EType asset_type, | 1324 | LLAssetType::EType asset_type, |
1314 | LLStoreAssetCallback callback, | 1325 | LLStoreAssetCallback callback, |
@@ -1320,13 +1331,13 @@ void LLAssetStorage::storeAssetData( | |||
1320 | { | 1331 | { |
1321 | llwarns << "storeAssetData: wrong version called" << llendl; | 1332 | llwarns << "storeAssetData: wrong version called" << llendl; |
1322 | // LLAssetStorage metric: Virtual base call | 1333 | // LLAssetStorage metric: Virtual base call |
1323 | reportMetric( asset_id, asset_type, NULL, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 3" ); | 1334 | reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 3" ); |
1324 | } | 1335 | } |
1325 | 1336 | ||
1326 | // virtual | 1337 | // virtual |
1327 | // this does nothing, viewer and sim both override this. | 1338 | // this does nothing, viewer and sim both override this. |
1328 | void LLAssetStorage::storeAssetData( | 1339 | void LLAssetStorage::storeAssetData( |
1329 | const char* filename, | 1340 | const std::string& filename, |
1330 | const LLTransactionID &transactoin_id, | 1341 | const LLTransactionID &transactoin_id, |
1331 | LLAssetType::EType asset_type, | 1342 | LLAssetType::EType asset_type, |
1332 | LLStoreAssetCallback callback, | 1343 | LLStoreAssetCallback callback, |
@@ -1338,7 +1349,7 @@ void LLAssetStorage::storeAssetData( | |||
1338 | { | 1349 | { |
1339 | llwarns << "storeAssetData: wrong version called" << llendl; | 1350 | llwarns << "storeAssetData: wrong version called" << llendl; |
1340 | // LLAssetStorage metric: Virtual base call | 1351 | // LLAssetStorage metric: Virtual base call |
1341 | reportMetric( LLUUID::null, asset_type, NULL, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 4" ); | 1352 | reportMetric( LLUUID::null, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 4" ); |
1342 | } | 1353 | } |
1343 | 1354 | ||
1344 | // static | 1355 | // static |
@@ -1385,9 +1396,9 @@ void LLAssetStorage::clearTempAssetData() | |||
1385 | { } | 1396 | { } |
1386 | 1397 | ||
1387 | // static | 1398 | // static |
1388 | void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::EType asset_type, const char *filename, | 1399 | void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::EType asset_type, const std::string& in_filename, |
1389 | const LLUUID& agent_id, S32 asset_size, EMetricResult result, | 1400 | const LLUUID& agent_id, S32 asset_size, EMetricResult result, |
1390 | const char *file, const S32 line, const char *message ) | 1401 | const char *file, const S32 line, const std::string& in_message ) |
1391 | { | 1402 | { |
1392 | if( !metric_recipient ) | 1403 | if( !metric_recipient ) |
1393 | { | 1404 | { |
@@ -1395,18 +1406,13 @@ void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::ET | |||
1395 | return; | 1406 | return; |
1396 | } | 1407 | } |
1397 | 1408 | ||
1398 | filename = filename ? filename : ""; | 1409 | std::string filename(in_filename); |
1399 | file = file ? file : ""; | 1410 | if (filename.empty()) |
1400 | 1411 | filename = ll_safe_string(file); | |
1401 | // Create revised message - message = "message :: file:line" | 1412 | |
1402 | std::string new_message; //( message ); | 1413 | // Create revised message - new_message = "in_message :: file:line" |
1403 | new_message = message; // << " " << file << " " << line; | 1414 | std::stringstream new_message; |
1404 | new_message += " :: "; | 1415 | new_message << in_message << " :: " << filename << ":" << line; |
1405 | new_message += filename; | ||
1406 | char line_string[16]; | ||
1407 | sprintf( line_string, ":%d", line ); | ||
1408 | new_message += line_string; | ||
1409 | message = new_message.c_str(); | ||
1410 | 1416 | ||
1411 | // Change always_report to true if debugging... do not check it in this way | 1417 | // Change always_report to true if debugging... do not check it in this way |
1412 | static bool always_report = false; | 1418 | static bool always_report = false; |
@@ -1419,15 +1425,68 @@ void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::ET | |||
1419 | LLSD stats; | 1425 | LLSD stats; |
1420 | stats["asset_id"] = asset_id; | 1426 | stats["asset_id"] = asset_id; |
1421 | stats["asset_type"] = asset_type; | 1427 | stats["asset_type"] = asset_type; |
1422 | stats["filename"] = filename? filename : ""; | 1428 | stats["filename"] = filename; |
1423 | stats["agent_id"] = agent_id; | 1429 | stats["agent_id"] = agent_id; |
1424 | stats["asset_size"] = (S32)asset_size; | 1430 | stats["asset_size"] = (S32)asset_size; |
1425 | stats["result"] = (S32)result; | 1431 | stats["result"] = (S32)result; |
1426 | 1432 | ||
1427 | metric_recipient->recordEventDetails( metric_name, message, success, stats); | 1433 | metric_recipient->recordEventDetails( metric_name, new_message.str(), success, stats); |
1428 | } | 1434 | } |
1429 | else | 1435 | else |
1430 | { | 1436 | { |
1431 | metric_recipient->recordEvent(metric_name, message, success); | 1437 | metric_recipient->recordEvent(metric_name, new_message.str(), success); |
1438 | } | ||
1439 | } | ||
1440 | |||
1441 | |||
1442 | // Check if an asset is in the toxic map. If it is, the entry is updated | ||
1443 | BOOL LLAssetStorage::isAssetToxic( const LLUUID& uuid ) | ||
1444 | { | ||
1445 | BOOL is_toxic = FALSE; | ||
1446 | |||
1447 | if ( !uuid.isNull() ) | ||
1448 | { | ||
1449 | toxic_asset_map_t::iterator iter = mToxicAssetMap.find( uuid ); | ||
1450 | if ( iter != mToxicAssetMap.end() ) | ||
1451 | { // Found toxic asset | ||
1452 | (*iter).second = LLFrameTimer::getTotalTime() + TOXIC_ASSET_LIFETIME; | ||
1453 | is_toxic = TRUE; | ||
1454 | } | ||
1432 | } | 1455 | } |
1456 | return is_toxic; | ||
1433 | } | 1457 | } |
1458 | |||
1459 | |||
1460 | |||
1461 | |||
1462 | // Clean the toxic asset list, remove old entries | ||
1463 | void LLAssetStorage::flushOldToxicAssets( BOOL force_it ) | ||
1464 | { | ||
1465 | // Scan and look for old entries | ||
1466 | U64 now = LLFrameTimer::getTotalTime(); | ||
1467 | toxic_asset_map_t::iterator iter = mToxicAssetMap.begin(); | ||
1468 | while ( iter != mToxicAssetMap.end() ) | ||
1469 | { | ||
1470 | if ( force_it | ||
1471 | || (*iter).second < now ) | ||
1472 | { // Too old - remove it | ||
1473 | mToxicAssetMap.erase( iter++ ); | ||
1474 | } | ||
1475 | else | ||
1476 | { | ||
1477 | iter++; | ||
1478 | } | ||
1479 | } | ||
1480 | } | ||
1481 | |||
1482 | |||
1483 | // Add an item to the toxic asset map | ||
1484 | void LLAssetStorage::markAssetToxic( const LLUUID& uuid ) | ||
1485 | { | ||
1486 | if ( !uuid.isNull() ) | ||
1487 | { | ||
1488 | // Set the value to the current time. Creates a new entry if needed | ||
1489 | mToxicAssetMap[ uuid ] = LLFrameTimer::getTotalTime() + TOXIC_ASSET_LIFETIME; | ||
1490 | } | ||
1491 | } | ||
1492 | |||