aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
authorAleric Inglewood2010-10-25 17:33:38 +0200
committerAleric Inglewood2010-10-25 17:33:38 +0200
commitb22b6bb6b16fcc0d908aa7899a80650ec1fe511d (patch)
tree2e922ae7ff29c98ce560353600b637b2f2a07134 /linden
parentFix possible crash on llassert_always(purge_list.size() >= entries_to_purge) (diff)
downloadmeta-impy-b22b6bb6b16fcc0d908aa7899a80650ec1fe511d.zip
meta-impy-b22b6bb6b16fcc0d908aa7899a80650ec1fe511d.tar.gz
meta-impy-b22b6bb6b16fcc0d908aa7899a80650ec1fe511d.tar.bz2
meta-impy-b22b6bb6b16fcc0d908aa7899a80650ec1fe511d.tar.xz
Fixed a locking issue with regard to texture cache purging.
Releasing a lock in the middle of a critical area isn't very smart.
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltexturecache.cpp20
-rw-r--r--linden/indra/newview/lltexturecache.h1
2 files changed, 14 insertions, 7 deletions
diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp
index ae0a63f..56f3719 100644
--- a/linden/indra/newview/lltexturecache.cpp
+++ b/linden/indra/newview/lltexturecache.cpp
@@ -1225,9 +1225,7 @@ void LLTextureCache::readHeaderCache()
1225 { 1225 {
1226 for (std::set<LLUUID>::iterator iter = purge_list.begin(); iter != purge_list.end(); ++iter) 1226 for (std::set<LLUUID>::iterator iter = purge_list.begin(); iter != purge_list.end(); ++iter)
1227 { 1227 {
1228 mHeaderMutex.unlock(); 1228 removeFromCacheLocked(*iter);
1229 removeFromCache(*iter);
1230 mHeaderMutex.lock();
1231 } 1229 }
1232 // If we removed any entries, we need to rebuild the entries list, 1230 // If we removed any entries, we need to rebuild the entries list,
1233 // write the header, and call this again 1231 // write the header, and call this again
@@ -1246,7 +1244,7 @@ void LLTextureCache::readHeaderCache()
1246 writeEntriesAndClose(new_entries); 1244 writeEntriesAndClose(new_entries);
1247 mHeaderMutex.unlock(); // unlock the mutex before calling again 1245 mHeaderMutex.unlock(); // unlock the mutex before calling again
1248 readHeaderCache(); // repeat with new entries file 1246 readHeaderCache(); // repeat with new entries file
1249 mHeaderMutex.lock(); 1247 return;
1250 } 1248 }
1251 else 1249 else
1252 { 1250 {
@@ -1611,7 +1609,6 @@ bool LLTextureCache::removeHeaderCacheEntry(const LLUUID& id)
1611{ 1609{
1612 if (!mReadOnly) 1610 if (!mReadOnly)
1613 { 1611 {
1614 LLMutexLock lock(&mHeaderMutex);
1615 Entry entry; 1612 Entry entry;
1616 S32 idx = openAndReadEntry(id, entry, false); 1613 S32 idx = openAndReadEntry(id, entry, false);
1617 if (idx >= 0) 1614 if (idx >= 0)
@@ -1628,17 +1625,26 @@ bool LLTextureCache::removeHeaderCacheEntry(const LLUUID& id)
1628 return false; 1625 return false;
1629} 1626}
1630 1627
1631void LLTextureCache::removeFromCache(const LLUUID& id) 1628void LLTextureCache::removeFromCacheLocked(const LLUUID& id)
1632{ 1629{
1633 //llwarns << "Removing texture from cache: " << id << llendl; 1630 //llwarns << "Removing texture from cache: " << id << llendl;
1634 if (!mReadOnly) 1631 if (!mReadOnly)
1635 { 1632 {
1636 removeHeaderCacheEntry(id); 1633 removeHeaderCacheEntry(id);
1637 LLMutexLock lock(&mHeaderMutex);
1638 LLAPRFile::remove(getTextureFileName(id)); 1634 LLAPRFile::remove(getTextureFileName(id));
1639 } 1635 }
1640} 1636}
1641 1637
1638void LLTextureCache::removeFromCache(const LLUUID& id)
1639{
1640 //llwarns << "Removing texture from cache: " << id << llendl;
1641 if (!mReadOnly)
1642 {
1643 LLMutexLock lock(&mHeaderMutex);
1644 LLTextureCache::removeFromCacheLocked(id);
1645 }
1646}
1647
1642////////////////////////////////////////////////////////////////////////////// 1648//////////////////////////////////////////////////////////////////////////////
1643 1649
1644LLTextureCache::ReadResponder::ReadResponder() 1650LLTextureCache::ReadResponder::ReadResponder()
diff --git a/linden/indra/newview/lltexturecache.h b/linden/indra/newview/lltexturecache.h
index 45804c2..c859b9a 100644
--- a/linden/indra/newview/lltexturecache.h
+++ b/linden/indra/newview/lltexturecache.h
@@ -158,6 +158,7 @@ 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 removeFromCacheLocked(const LLUUID& id);
161 162
162private: 163private:
163 // Internal 164 // Internal