Skip to content

Commit 76e1e48

Browse files
committed
#5346 Fix early exit crash
1 parent 6228a4c commit 76e1e48

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

indra/llcommon/workqueue.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ LL::WorkQueueBase::WorkQueueBase(const std::string& name, bool auto_shutdown)
3838
{
3939
// Register for "LLApp" events so we can implicitly close() on viewer shutdown
4040
std::string listener_name = "WorkQueue:" + getKey();
41-
LLEventPumps::instance().obtain("LLApp").listen(
41+
LLEventPumps* pump = LLEventPumps::getInstance();
42+
pump->obtain("LLApp").listen(
4243
listener_name,
4344
[this](const LLSD& stat)
4445
{
@@ -54,14 +55,25 @@ LL::WorkQueueBase::WorkQueueBase(const std::string& name, bool auto_shutdown)
5455

5556
// Store the listener name so we can unregister in the destructor
5657
mListenerName = listener_name;
58+
mPumpHandle = pump->getHandle();
5759
}
5860
}
5961

6062
LL::WorkQueueBase::~WorkQueueBase()
6163
{
62-
if (!mListenerName.empty() && !LLEventPumps::wasDeleted())
64+
if (!mListenerName.empty() && !mPumpHandle.isDead())
6365
{
64-
LLEventPumps::instance().obtain("LLApp").stopListening(mListenerName);
66+
// Due to shutdown order issues, use handle, not a singleton
67+
// and ignore fiber issue.
68+
try
69+
{
70+
LLEventPumps* pump = mPumpHandle.get();
71+
pump->obtain("LLApp").stopListening(mListenerName);
72+
}
73+
catch (const boost::fibers::lock_error&)
74+
{
75+
// Likely mutex is down, ignore
76+
}
6577
}
6678
}
6779

indra/llcommon/workqueue.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "llcoros.h"
1616
#include "llexception.h"
17+
#include "llhandle.h"
1718
#include "llinstancetracker.h"
1819
#include "llinstancetrackersubclass.h"
1920
#include "threadsafeschedule.h"
@@ -22,6 +23,9 @@
2223
#include <functional> // std::function
2324
#include <string>
2425

26+
class LLEventPumps;
27+
28+
2529
namespace LL
2630
{
2731

@@ -202,6 +206,8 @@ namespace LL
202206

203207
// Name used for the LLApp event listener (empty if not registered)
204208
std::string mListenerName;
209+
// Due to shutdown order issues, store by handle
210+
LLHandle<LLEventPumps> mPumpHandle;
205211
};
206212

207213
/*****************************************************************************

0 commit comments

Comments
 (0)