diff options
author | Armin Weatherwax | 2010-03-02 14:14:50 +0100 |
---|---|---|
committer | Armin Weatherwax | 2010-03-04 22:32:46 +0100 |
commit | e49a03d2c98228163e46d6bba7bc05bef4584468 (patch) | |
tree | b4d43387f15200f14ca54eff06bae674231b0f7b /linden/indra | |
parent | Aleric Inglewood: SNOW-408 Fix the case for a non-valid handle but abort set. (diff) | |
download | meta-impy-e49a03d2c98228163e46d6bba7bc05bef4584468.zip meta-impy-e49a03d2c98228163e46d6bba7bc05bef4584468.tar.gz meta-impy-e49a03d2c98228163e46d6bba7bc05bef4584468.tar.bz2 meta-impy-e49a03d2c98228163e46d6bba7bc05bef4584468.tar.xz |
Merov Linden: SNOW-435 mHeaderMutex recursive lock.
Diffstat (limited to 'linden/indra')
-rw-r--r-- | linden/indra/newview/lltexturecache.cpp | 38 | ||||
-rw-r--r-- | linden/indra/newview/lltexturecache.h | 2 |
2 files changed, 29 insertions, 11 deletions
diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index 706e408..3cedf73 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp | |||
@@ -816,7 +816,7 @@ bool LLTextureCache::updateTextureEntryList(const LLUUID& id, S32 bodysize) | |||
816 | bool res = false; | 816 | bool res = false; |
817 | bool purge = false; | 817 | bool purge = false; |
818 | { | 818 | { |
819 | LLMutexLock lock(&mHeaderMutex); | 819 | mHeaderMutex.lock(); |
820 | size_map_t::iterator iter1 = mTexturesSizeMap.find(id); | 820 | size_map_t::iterator iter1 = mTexturesSizeMap.find(id); |
821 | if (iter1 == mTexturesSizeMap.end() || iter1->second < bodysize) | 821 | if (iter1 == mTexturesSizeMap.end() || iter1->second < bodysize) |
822 | { | 822 | { |
@@ -834,6 +834,7 @@ bool LLTextureCache::updateTextureEntryList(const LLUUID& id, S32 bodysize) | |||
834 | { | 834 | { |
835 | // TODO: change to llwarns | 835 | // TODO: change to llwarns |
836 | llerrs << "Failed to open entry: " << id << llendl; | 836 | llerrs << "Failed to open entry: " << id << llendl; |
837 | mHeaderMutex.unlock(); | ||
837 | removeFromCache(id); | 838 | removeFromCache(id); |
838 | return false; | 839 | return false; |
839 | } | 840 | } |
@@ -860,6 +861,7 @@ bool LLTextureCache::updateTextureEntryList(const LLUUID& id, S32 bodysize) | |||
860 | { | 861 | { |
861 | mDoPurge = TRUE; | 862 | mDoPurge = TRUE; |
862 | } | 863 | } |
864 | mHeaderMutex.unlock(); | ||
863 | return res; | 865 | return res; |
864 | } | 866 | } |
865 | 867 | ||
@@ -884,6 +886,8 @@ void LLTextureCache::setDirNames(ELLPath location) | |||
884 | 886 | ||
885 | void LLTextureCache::purgeCache(ELLPath location) | 887 | void LLTextureCache::purgeCache(ELLPath location) |
886 | { | 888 | { |
889 | LLMutexLock lock(&mHeaderMutex); | ||
890 | |||
887 | if (!mReadOnly) | 891 | if (!mReadOnly) |
888 | { | 892 | { |
889 | setDirNames(location); | 893 | setDirNames(location); |
@@ -1140,7 +1144,7 @@ void LLTextureCache::writeEntriesAndClose(const std::vector<Entry>& entries) | |||
1140 | // Called from either the main thread or the worker thread | 1144 | // Called from either the main thread or the worker thread |
1141 | void LLTextureCache::readHeaderCache() | 1145 | void LLTextureCache::readHeaderCache() |
1142 | { | 1146 | { |
1143 | LLMutexLock lock(&mHeaderMutex); | 1147 | mHeaderMutex.lock(); |
1144 | 1148 | ||
1145 | mLRU.clear(); // always clear the LRU | 1149 | mLRU.clear(); // always clear the LRU |
1146 | 1150 | ||
@@ -1169,7 +1173,7 @@ void LLTextureCache::readHeaderCache() | |||
1169 | const LLUUID& id = entry.mID; | 1173 | const LLUUID& id = entry.mID; |
1170 | if (entry.mImageSize < 0) | 1174 | if (entry.mImageSize < 0) |
1171 | { | 1175 | { |
1172 | // This will be in the Free List, don't put it in the LRY | 1176 | // This will be in the Free List, don't put it in the LRU |
1173 | ++empty_entries; | 1177 | ++empty_entries; |
1174 | } | 1178 | } |
1175 | else | 1179 | else |
@@ -1217,7 +1221,9 @@ void LLTextureCache::readHeaderCache() | |||
1217 | { | 1221 | { |
1218 | for (std::vector<LLUUID>::iterator iter = purge_list.begin(); iter != purge_list.end(); ++iter) | 1222 | for (std::vector<LLUUID>::iterator iter = purge_list.begin(); iter != purge_list.end(); ++iter) |
1219 | { | 1223 | { |
1224 | mHeaderMutex.unlock(); | ||
1220 | removeFromCache(*iter); | 1225 | removeFromCache(*iter); |
1226 | mHeaderMutex.lock(); | ||
1221 | } | 1227 | } |
1222 | // If we removed any entries, we need to rebuild the entries list, | 1228 | // If we removed any entries, we need to rebuild the entries list, |
1223 | // write the header, and call this again | 1229 | // write the header, and call this again |
@@ -1233,7 +1239,9 @@ void LLTextureCache::readHeaderCache() | |||
1233 | llassert_always(new_entries.size() <= sCacheMaxEntries); | 1239 | llassert_always(new_entries.size() <= sCacheMaxEntries); |
1234 | mHeaderEntriesInfo.mEntries = new_entries.size(); | 1240 | mHeaderEntriesInfo.mEntries = new_entries.size(); |
1235 | writeEntriesAndClose(new_entries); | 1241 | writeEntriesAndClose(new_entries); |
1242 | mHeaderMutex.unlock(); // unlock the mutex before calling again | ||
1236 | readHeaderCache(); // repeat with new entries file | 1243 | readHeaderCache(); // repeat with new entries file |
1244 | mHeaderMutex.lock(); | ||
1237 | } | 1245 | } |
1238 | else | 1246 | else |
1239 | { | 1247 | { |
@@ -1241,6 +1249,7 @@ void LLTextureCache::readHeaderCache() | |||
1241 | } | 1249 | } |
1242 | } | 1250 | } |
1243 | } | 1251 | } |
1252 | mHeaderMutex.unlock(); | ||
1244 | } | 1253 | } |
1245 | 1254 | ||
1246 | ////////////////////////////////////////////////////////////////////////////// | 1255 | ////////////////////////////////////////////////////////////////////////////// |
@@ -1285,9 +1294,12 @@ void LLTextureCache::purgeTextures(bool validate) | |||
1285 | return; | 1294 | return; |
1286 | } | 1295 | } |
1287 | 1296 | ||
1288 | // *FIX:Mani - watchdog off. | 1297 | if (!mThreaded) |
1289 | LLAppViewer::instance()->pauseMainloopTimeout(); | 1298 | { |
1290 | 1299 | // *FIX:Mani - watchdog off. | |
1300 | LLAppViewer::instance()->pauseMainloopTimeout(); | ||
1301 | } | ||
1302 | |||
1291 | LLMutexLock lock(&mHeaderMutex); | 1303 | LLMutexLock lock(&mHeaderMutex); |
1292 | 1304 | ||
1293 | llinfos << "TEXTURE CACHE: Purging." << llendl; | 1305 | llinfos << "TEXTURE CACHE: Purging." << llendl; |
@@ -1379,8 +1391,11 @@ void LLTextureCache::purgeTextures(bool validate) | |||
1379 | 1391 | ||
1380 | writeEntriesAndClose(entries); | 1392 | writeEntriesAndClose(entries); |
1381 | 1393 | ||
1382 | // *FIX:Mani - watchdog back on. | 1394 | if (!mThreaded) |
1383 | LLAppViewer::instance()->resumeMainloopTimeout(); | 1395 | { |
1396 | // *FIX:Mani - watchdog back on. | ||
1397 | LLAppViewer::instance()->resumeMainloopTimeout(); | ||
1398 | } | ||
1384 | 1399 | ||
1385 | LL_INFOS("TextureCache") << "TEXTURE CACHE:" | 1400 | LL_INFOS("TextureCache") << "TEXTURE CACHE:" |
1386 | << " PURGED: " << purge_count | 1401 | << " PURGED: " << purge_count |
@@ -1434,7 +1449,7 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, S32& imagesize) | |||
1434 | // Writes imagesize to the header, updates timestamp | 1449 | // Writes imagesize to the header, updates timestamp |
1435 | S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, S32 imagesize) | 1450 | S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, S32 imagesize) |
1436 | { | 1451 | { |
1437 | LLMutexLock lock(&mHeaderMutex); | 1452 | mHeaderMutex.lock(); |
1438 | llassert_always(imagesize >= 0); | 1453 | llassert_always(imagesize >= 0); |
1439 | Entry entry; | 1454 | Entry entry; |
1440 | S32 idx = openAndReadEntry(id, entry, true); | 1455 | S32 idx = openAndReadEntry(id, entry, true); |
@@ -1442,11 +1457,15 @@ S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, S32 imagesize) | |||
1442 | { | 1457 | { |
1443 | entry.mImageSize = imagesize; | 1458 | entry.mImageSize = imagesize; |
1444 | writeEntryAndClose(idx, entry); | 1459 | writeEntryAndClose(idx, entry); |
1460 | mHeaderMutex.unlock(); | ||
1445 | } | 1461 | } |
1446 | else // retry | 1462 | else // retry |
1447 | { | 1463 | { |
1464 | mHeaderMutex.unlock(); | ||
1448 | readHeaderCache(); // We couldn't write an entry, so refresh the LRU | 1465 | readHeaderCache(); // We couldn't write an entry, so refresh the LRU |
1466 | mHeaderMutex.lock(); | ||
1449 | llassert_always(!mLRU.empty() || mHeaderEntriesInfo.mEntries < sCacheMaxEntries); | 1467 | llassert_always(!mLRU.empty() || mHeaderEntriesInfo.mEntries < sCacheMaxEntries); |
1468 | mHeaderMutex.unlock(); | ||
1450 | idx = setHeaderCacheEntry(id, imagesize); // assert above ensures no inf. recursion | 1469 | idx = setHeaderCacheEntry(id, imagesize); // assert above ensures no inf. recursion |
1451 | } | 1470 | } |
1452 | return idx; | 1471 | return idx; |
@@ -1610,6 +1629,7 @@ void LLTextureCache::removeFromCache(const LLUUID& id) | |||
1610 | if (!mReadOnly) | 1629 | if (!mReadOnly) |
1611 | { | 1630 | { |
1612 | removeHeaderCacheEntry(id); | 1631 | removeHeaderCacheEntry(id); |
1632 | LLMutexLock lock(&mHeaderMutex); | ||
1613 | LLAPRFile::remove(getTextureFileName(id)); | 1633 | LLAPRFile::remove(getTextureFileName(id)); |
1614 | } | 1634 | } |
1615 | } | 1635 | } |
diff --git a/linden/indra/newview/lltexturecache.h b/linden/indra/newview/lltexturecache.h index e4f6934..45804c2 100644 --- a/linden/indra/newview/lltexturecache.h +++ b/linden/indra/newview/lltexturecache.h | |||
@@ -158,8 +158,6 @@ private: | |||
158 | S32 getHeaderCacheEntry(const LLUUID& id, S32& imagesize); | 158 | S32 getHeaderCacheEntry(const LLUUID& id, S32& imagesize); |
159 | S32 setHeaderCacheEntry(const LLUUID& id, S32 imagesize); | 159 | S32 setHeaderCacheEntry(const LLUUID& id, S32 imagesize); |
160 | bool removeHeaderCacheEntry(const LLUUID& id); | 160 | bool removeHeaderCacheEntry(const LLUUID& id); |
161 | void lockHeaders() { mHeaderMutex.lock(); } | ||
162 | void unlockHeaders() { mHeaderMutex.unlock(); } | ||
163 | 161 | ||
164 | private: | 162 | private: |
165 | // Internal | 163 | // Internal |