aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltexturecache.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltexturecache.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp
index 46c125f..a9b7f81 100644
--- a/linden/indra/newview/lltexturecache.cpp
+++ b/linden/indra/newview/lltexturecache.cpp
@@ -372,9 +372,10 @@ bool LLTextureCacheRemoteWorker::doRead()
372 if (!done && (mState == LOCAL)) 372 if (!done && (mState == LOCAL))
373 { 373 {
374 llassert(local_size != 0); // we're assuming there is a non empty local file here... 374 llassert(local_size != 0); // we're assuming there is a non empty local file here...
375 if (!mDataSize || mDataSize > local_size) 375 llassert(mReadData == NULL);
376 if (!mDataSize || mDataSize > (local_size - mOffset))
376 { 377 {
377 mDataSize = local_size; 378 mDataSize = local_size - mOffset;
378 } 379 }
379 // Allocate read buffer 380 // Allocate read buffer
380 mReadData = new U8[mDataSize]; 381 mReadData = new U8[mDataSize];
@@ -1176,7 +1177,7 @@ void LLTextureCache::readHeaderCache()
1176 { 1177 {
1177 Entry& entry = entries[i]; 1178 Entry& entry = entries[i];
1178 const LLUUID& id = entry.mID; 1179 const LLUUID& id = entry.mID;
1179 if (entry.mImageSize < 0) 1180 if (entry.mImageSize <= 0)
1180 { 1181 {
1181 // 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
1182 ++empty_entries; 1183 ++empty_entries;
@@ -1189,7 +1190,7 @@ void LLTextureCache::readHeaderCache()
1189 if (entry.mBodySize > entry.mImageSize) 1190 if (entry.mBodySize > entry.mImageSize)
1190 { 1191 {
1191 // Shouldn't happen, failsafe only 1192 // Shouldn't happen, failsafe only
1192 llwarns << "Bad entry: " << i << ": " << id << ": BodySize: " << entry.mBodySize << llendl; 1193 llwarns << "Bad entry: " << i << ": " << entry.mID << ": BodySize: " << entry.mBodySize << llendl;
1193 purge_list.push_back(id); 1194 purge_list.push_back(id);
1194 } 1195 }
1195 } 1196 }
@@ -1200,15 +1201,17 @@ void LLTextureCache::readHeaderCache()
1200 // Special case: cache size was reduced, need to remove entries 1201 // Special case: cache size was reduced, need to remove entries
1201 // 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
1202 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;
1203 if (entries_to_purge > 0) 1205 if (entries_to_purge > 0)
1204 { 1206 {
1205 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)
1206 { 1208 {
1207 purge_list.push_back(iter->second); 1209 purge_list.push_back(iter->second);
1208 if (--entries_to_purge <= 0) 1210 if (purge_list.size() >= entries_to_purge)
1209 break; 1211 break;
1210 } 1212 }
1211 } 1213 }
1214 llassert_always(purge_list.size() >= entries_to_purge);
1212 } 1215 }
1213 else 1216 else
1214 { 1217 {
@@ -1236,13 +1239,14 @@ void LLTextureCache::readHeaderCache()
1236 for (U32 i=0; i<num_entries; i++) 1239 for (U32 i=0; i<num_entries; i++)
1237 { 1240 {
1238 const Entry& entry = entries[i]; 1241 const Entry& entry = entries[i];
1239 if (entry.mImageSize >=0) 1242 if (entry.mImageSize > 0)
1240 { 1243 {
1241 new_entries.push_back(entry); 1244 new_entries.push_back(entry);
1242 } 1245 }
1243 } 1246 }
1244 llassert_always(new_entries.size() <= sCacheMaxEntries); 1247 llassert_always(new_entries.size() <= sCacheMaxEntries);
1245 mHeaderEntriesInfo.mEntries = new_entries.size(); 1248 mHeaderEntriesInfo.mEntries = new_entries.size();
1249 writeEntriesHeader();
1246 writeEntriesAndClose(new_entries); 1250 writeEntriesAndClose(new_entries);
1247 mHeaderMutex.unlock(); // unlock the mutex before calling again 1251 mHeaderMutex.unlock(); // unlock the mutex before calling again
1248 readHeaderCache(); // repeat with new entries file 1252 readHeaderCache(); // repeat with new entries file
@@ -1250,7 +1254,7 @@ void LLTextureCache::readHeaderCache()
1250 } 1254 }
1251 else 1255 else
1252 { 1256 {
1253 writeEntriesAndClose(entries); 1257 //entries are not changed, nothing here.
1254 } 1258 }
1255 } 1259 }
1256 } 1260 }