aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJacek Antonelli2010-09-24 22:33:52 -0500
committerMcCabe Maxsted2010-10-08 23:13:38 -0700
commitf38d43a3bdce210935c01ee3ecd58b7b86fab69e (patch)
treeca86fd2c2c53ed440503baa4fe54b882f6e93d73
parentTiny layout tweaks to accomodate different font widths. (diff)
downloadmeta-impy-f38d43a3bdce210935c01ee3ecd58b7b86fab69e.zip
meta-impy-f38d43a3bdce210935c01ee3ecd58b7b86fab69e.tar.gz
meta-impy-f38d43a3bdce210935c01ee3ecd58b7b86fab69e.tar.bz2
meta-impy-f38d43a3bdce210935c01ee3ecd58b7b86fab69e.tar.xz
Possible fix for an infinite loop in LLTextureCache.
Backported a few changes from pre-LGPL Viewer 2.
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltexturecache.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp
index 0c35b32..a9b7f81 100644
--- a/linden/indra/newview/lltexturecache.cpp
+++ b/linden/indra/newview/lltexturecache.cpp
@@ -1177,7 +1177,7 @@ void LLTextureCache::readHeaderCache()
1177 { 1177 {
1178 Entry& entry = entries[i]; 1178 Entry& entry = entries[i];
1179 const LLUUID& id = entry.mID; 1179 const LLUUID& id = entry.mID;
1180 if (entry.mImageSize < 0) 1180 if (entry.mImageSize <= 0)
1181 { 1181 {
1182 // This will be in the Free List, don't put it in the LRU 1182 // This will be in the Free List, don't put it in the LRU
1183 ++empty_entries; 1183 ++empty_entries;
@@ -1190,7 +1190,7 @@ void LLTextureCache::readHeaderCache()
1190 if (entry.mBodySize > entry.mImageSize) 1190 if (entry.mBodySize > entry.mImageSize)
1191 { 1191 {
1192 // Shouldn't happen, failsafe only 1192 // Shouldn't happen, failsafe only
1193 llwarns << "Bad entry: " << i << ": " << id << ": BodySize: " << entry.mBodySize << llendl; 1193 llwarns << "Bad entry: " << i << ": " << entry.mID << ": BodySize: " << entry.mBodySize << llendl;
1194 purge_list.push_back(id); 1194 purge_list.push_back(id);
1195 } 1195 }
1196 } 1196 }
@@ -1201,15 +1201,17 @@ void LLTextureCache::readHeaderCache()
1201 // Special case: cache size was reduced, need to remove entries 1201 // Special case: cache size was reduced, need to remove entries
1202 // Note: After we prune entries, we will call this again and create the LRU 1202 // Note: After we prune entries, we will call this again and create the LRU
1203 U32 entries_to_purge = (num_entries-empty_entries) - sCacheMaxEntries; 1203 U32 entries_to_purge = (num_entries-empty_entries) - sCacheMaxEntries;
1204 llinfos << "Texture Cache Entries: " << num_entries << " Max: " << sCacheMaxEntries << " Empty: " << empty_entries << " Purging: " << entries_to_purge << llendl;
1204 if (entries_to_purge > 0) 1205 if (entries_to_purge > 0)
1205 { 1206 {
1206 for (std::set<lru_data_t>::iterator iter = lru.begin(); iter != lru.end(); ++iter) 1207 for (std::set<lru_data_t>::iterator iter = lru.begin(); iter != lru.end(); ++iter)
1207 { 1208 {
1208 purge_list.push_back(iter->second); 1209 purge_list.push_back(iter->second);
1209 if (--entries_to_purge <= 0) 1210 if (purge_list.size() >= entries_to_purge)
1210 break; 1211 break;
1211 } 1212 }
1212 } 1213 }
1214 llassert_always(purge_list.size() >= entries_to_purge);
1213 } 1215 }
1214 else 1216 else
1215 { 1217 {
@@ -1237,13 +1239,14 @@ void LLTextureCache::readHeaderCache()
1237 for (U32 i=0; i<num_entries; i++) 1239 for (U32 i=0; i<num_entries; i++)
1238 { 1240 {
1239 const Entry& entry = entries[i]; 1241 const Entry& entry = entries[i];
1240 if (entry.mImageSize >=0) 1242 if (entry.mImageSize > 0)
1241 { 1243 {
1242 new_entries.push_back(entry); 1244 new_entries.push_back(entry);
1243 } 1245 }
1244 } 1246 }
1245 llassert_always(new_entries.size() <= sCacheMaxEntries); 1247 llassert_always(new_entries.size() <= sCacheMaxEntries);
1246 mHeaderEntriesInfo.mEntries = new_entries.size(); 1248 mHeaderEntriesInfo.mEntries = new_entries.size();
1249 writeEntriesHeader();
1247 writeEntriesAndClose(new_entries); 1250 writeEntriesAndClose(new_entries);
1248 mHeaderMutex.unlock(); // unlock the mutex before calling again 1251 mHeaderMutex.unlock(); // unlock the mutex before calling again
1249 readHeaderCache(); // repeat with new entries file 1252 readHeaderCache(); // repeat with new entries file
@@ -1251,7 +1254,7 @@ void LLTextureCache::readHeaderCache()
1251 } 1254 }
1252 else 1255 else
1253 { 1256 {
1254 writeEntriesAndClose(entries); 1257 //entries are not changed, nothing here.
1255 } 1258 }
1256 } 1259 }
1257 } 1260 }