aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/llcommon/llthread.cpp11
-rw-r--r--linden/indra/llcommon/llthread.h3
-rw-r--r--linden/indra/newview/lltexturefetch.cpp28
-rw-r--r--linden/indra/newview/lltexturefetch.h9
4 files changed, 35 insertions, 16 deletions
diff --git a/linden/indra/llcommon/llthread.cpp b/linden/indra/llcommon/llthread.cpp
index b39ffb6..60ccd5c 100644
--- a/linden/indra/llcommon/llthread.cpp
+++ b/linden/indra/llcommon/llthread.cpp
@@ -322,6 +322,17 @@ bool LLMutex::isLocked()
322 } 322 }
323} 323}
324 324
325//trys to grab a lock and if sucessful returns true
326bool LLMutex::tryLock()
327{
328 apr_status_t status = apr_thread_mutex_trylock(mAPRMutexp);
329 if (APR_STATUS_IS_EBUSY(status))
330 {
331 return false;
332 }
333 return true;
334}
335
325//============================================================================ 336//============================================================================
326 337
327LLCondition::LLCondition(apr_pool_t *poolp) : 338LLCondition::LLCondition(apr_pool_t *poolp) :
diff --git a/linden/indra/llcommon/llthread.h b/linden/indra/llcommon/llthread.h
index 721b6e7..d773fa4 100644
--- a/linden/indra/llcommon/llthread.h
+++ b/linden/indra/llcommon/llthread.h
@@ -134,7 +134,8 @@ public:
134 void lock(); // blocks 134 void lock(); // blocks
135 void unlock(); 135 void unlock();
136 bool isLocked(); // non-blocking, but does do a lock/unlock so not free 136 bool isLocked(); // non-blocking, but does do a lock/unlock so not free
137 137 bool tryLock(); //non-blocking, but not free, returns true if grabed lock
138
138protected: 139protected:
139 apr_thread_mutex_t *mAPRMutexp; 140 apr_thread_mutex_t *mAPRMutexp;
140 apr_pool_t *mAPRPoolp; 141 apr_pool_t *mAPRPoolp;
diff --git a/linden/indra/newview/lltexturefetch.cpp b/linden/indra/newview/lltexturefetch.cpp
index 8ff9e9f..3a5665c 100644
--- a/linden/indra/newview/lltexturefetch.cpp
+++ b/linden/indra/newview/lltexturefetch.cpp
@@ -744,13 +744,17 @@ bool LLTextureFetchWorker::doWork(S32 param)
744 } 744 }
745 else if (mSentRequest == UNSENT) 745 else if (mSentRequest == UNSENT)
746 { 746 {
747 // Add this to the network queue and sit here. 747 if(mFetcher->mQueueMutex.tryLock())
748 // LLTextureFetch::update() will send off a request which will change our state 748 {
749 mRequestedSize = mDesiredSize; 749 // Add this to the network queue and sit here.
750 mRequestedDiscard = mDesiredDiscard; 750 // LLTextureFetch::update() will send off a request which will change our state
751 mSentRequest = QUEUED; 751 mRequestedSize = mDesiredSize;
752 mFetcher->addToNetworkQueue(this); 752 mRequestedDiscard = mDesiredDiscard;
753 setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); 753 mSentRequest = QUEUED;
754 mFetcher->addToNetworkQueue(this);
755 setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
756 mFetcher->mQueueMutex.unlock();
757 }
754 return false; 758 return false;
755 } 759 }
756 else 760 else
@@ -800,7 +804,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
800 // Set the throttle to the entire bandwidth, assuming UDP packets will get priority 804 // Set the throttle to the entire bandwidth, assuming UDP packets will get priority
801 // when they are needed 805 // when they are needed
802 F32 max_bandwidth = mFetcher->mMaxBandwidth; 806 F32 max_bandwidth = mFetcher->mMaxBandwidth;
803 if ((mFetcher->getHTTPQueueSize() >= HTTP_QUEUE_MAX_SIZE) || 807 if ((mFetcher->getNumHTTPRequests() >= HTTP_QUEUE_MAX_SIZE) ||
804 (mFetcher->getTextureBandwidth() > max_bandwidth)) 808 (mFetcher->getTextureBandwidth() > max_bandwidth))
805 { 809 {
806 // Make normal priority and return (i.e. wait until there is room in the queue) 810 // Make normal priority and return (i.e. wait until there is room in the queue)
@@ -1469,12 +1473,13 @@ void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel)
1469 } 1473 }
1470} 1474}
1471 1475
1476// Need to hold mQueueMutex when entering this function SNOW-196
1477// Snowglobe ToDo fix holding mQueueMutex over the entire function, we only need
1478// it for the mRequestMap access
1472// protected 1479// protected
1473void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker) 1480void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker)
1474{ 1481{
1475 mQueueMutex.lock();
1476 bool is_worker_in_request_map = (mRequestMap.find(worker->mID) != mRequestMap.end()); 1482 bool is_worker_in_request_map = (mRequestMap.find(worker->mID) != mRequestMap.end());
1477 mQueueMutex.unlock();
1478 1483
1479 LLMutexLock lock(&mNetworkQueueMutex); 1484 LLMutexLock lock(&mNetworkQueueMutex);
1480 if (is_worker_in_request_map) 1485 if (is_worker_in_request_map)
@@ -1916,6 +1921,7 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8
1916 { 1921 {
1917// llwarns << "Received header for non active worker: " << id << llendl; 1922// llwarns << "Received header for non active worker: " << id << llendl;
1918 ++mBadPacketCount; 1923 ++mBadPacketCount;
1924 LLMutexLock lock2(&mNetworkQueueMutex);
1919 mCancelQueue[host].insert(id); 1925 mCancelQueue[host].insert(id);
1920 return false; 1926 return false;
1921 } 1927 }
@@ -1944,6 +1950,7 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8
1944 if (!res) 1950 if (!res)
1945 { 1951 {
1946 ++mBadPacketCount; 1952 ++mBadPacketCount;
1953 LLMutexLock lock2(&mNetworkQueueMutex);
1947 mCancelQueue[host].insert(id); 1954 mCancelQueue[host].insert(id);
1948 } 1955 }
1949 else 1956 else
@@ -1988,6 +1995,7 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
1988 if (!res) 1995 if (!res)
1989 { 1996 {
1990 ++mBadPacketCount; 1997 ++mBadPacketCount;
1998 LLMutexLock lock2(&mNetworkQueueMutex);
1991 mCancelQueue[host].insert(id); 1999 mCancelQueue[host].insert(id);
1992 return false; 2000 return false;
1993 } 2001 }
diff --git a/linden/indra/newview/lltexturefetch.h b/linden/indra/newview/lltexturefetch.h
index c48f609..5eca0ba 100644
--- a/linden/indra/newview/lltexturefetch.h
+++ b/linden/indra/newview/lltexturefetch.h
@@ -76,8 +76,8 @@ public:
76 S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p, 76 S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p,
77 U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p); 77 U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p);
78 void dump(); 78 void dump();
79 S32 getNumRequests() { return mRequestMap.size(); } 79 S32 getNumRequests() const { LLMutexLock lock(&mQueueMutex); return mRequestMap.size(); }
80 S32 getNumHTTPRequests() { return mHTTPTextureQueue.size(); } 80 S32 getNumHTTPRequests() const { LLMutexLock lock(&mNetworkQueueMutex); return mHTTPTextureQueue.size(); }
81 81
82 // Public for access by callbacks 82 // Public for access by callbacks
83 void lockQueue() { mQueueMutex.lock(); } 83 void lockQueue() { mQueueMutex.lock(); }
@@ -91,7 +91,6 @@ protected:
91 void removeFromNetworkQueue(LLTextureFetchWorker* worker, bool cancel); 91 void removeFromNetworkQueue(LLTextureFetchWorker* worker, bool cancel);
92 void addToHTTPQueue(const LLUUID& id); 92 void addToHTTPQueue(const LLUUID& id);
93 void removeFromHTTPQueue(const LLUUID& id); 93 void removeFromHTTPQueue(const LLUUID& id);
94 S32 getHTTPQueueSize() { return (S32)mHTTPTextureQueue.size(); }
95 void removeRequest(LLTextureFetchWorker* worker, bool cancel); 94 void removeRequest(LLTextureFetchWorker* worker, bool cancel);
96 // Called from worker thread (during doWork) 95 // Called from worker thread (during doWork)
97 void processCurlRequests(); 96 void processCurlRequests();
@@ -110,8 +109,8 @@ public:
110 S32 mBadPacketCount; 109 S32 mBadPacketCount;
111 110
112private: 111private:
113 LLMutex mQueueMutex; 112 mutable LLMutex mQueueMutex;
114 LLMutex mNetworkQueueMutex; 113 mutable LLMutex mNetworkQueueMutex;
115 114
116 LLTextureCache* mTextureCache; 115 LLTextureCache* mTextureCache;
117 LLImageDecodeThread* mImageDecodeThread; 116 LLImageDecodeThread* mImageDecodeThread;