Fix deinitialization order fiasco.
This commit is contained in:
@@ -56,12 +56,17 @@ PerHostRequestQueuePtr PerHostRequestQueue::instance(std::string const& hostname
|
|||||||
//static
|
//static
|
||||||
void PerHostRequestQueue::release(PerHostRequestQueuePtr& instance)
|
void PerHostRequestQueue::release(PerHostRequestQueuePtr& instance)
|
||||||
{
|
{
|
||||||
if (instance->lastone())
|
if (instance->exactly_two_left()) // Being 'instance' and the one in sInstanceMap.
|
||||||
{
|
{
|
||||||
|
// The viewer can be have left main() we can't access the global sInstanceMap anymore.
|
||||||
|
if (LLApp::isStopped())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
instance_map_wat instance_map_w(sInstanceMap);
|
instance_map_wat instance_map_w(sInstanceMap);
|
||||||
// It is possible that 'lastone' is not up to date anymore.
|
// It is possible that 'exactly_two_left' is not up to date anymore.
|
||||||
// Therefore, recheck the condition now that we have locked sInstanceMap.
|
// Therefore, recheck the condition now that we have locked sInstanceMap.
|
||||||
if (!instance->lastone())
|
if (!instance->exactly_two_left())
|
||||||
{
|
{
|
||||||
// Some other thread added this host in the meantime.
|
// Some other thread added this host in the meantime.
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class PerHostRequestQueue {
|
|||||||
class RefCountedThreadSafePerHostRequestQueue : public threadsafe_PerHostRequestQueue {
|
class RefCountedThreadSafePerHostRequestQueue : public threadsafe_PerHostRequestQueue {
|
||||||
public:
|
public:
|
||||||
RefCountedThreadSafePerHostRequestQueue(void) : mReferenceCount(0) { }
|
RefCountedThreadSafePerHostRequestQueue(void) : mReferenceCount(0) { }
|
||||||
bool lastone(void) const { llassert(mReferenceCount >= 2); return mReferenceCount == 2; }
|
bool exactly_two_left(void) const { return mReferenceCount == 2; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Used by PerHostRequestQueuePtr. Object is deleted when reference count reaches zero.
|
// Used by PerHostRequestQueuePtr. Object is deleted when reference count reaches zero.
|
||||||
|
|||||||
Reference in New Issue
Block a user