SenseApiLib:Add isBeingDestroyed atomic flag for getter bailout

Since we have no choice but to access the sh_ptr<SenseApiLib> for
a lib before we can get its Qutex, we use this flag to ensure that
we can know whether the SenseApiLib data structure and its Qutex
are still valid when we enter -- i.e, we ensure that the SenseApiLib
object wasn't destroyed under our feet.
This commit is contained in:
2025-09-30 20:48:45 -04:00
parent 1bad358921
commit 07609c6d6c
3 changed files with 30 additions and 32 deletions
+3 -1
View File
@@ -3,6 +3,7 @@
#include <string>
#include <memory>
#include <atomic>
#include <vector>
#include <dlfcn.h>
#include <functional>
@@ -30,7 +31,7 @@ public:
SenseApiLib(
const std::string& path, void *_dlopen_handle,
SMO_GET_SENSE_API_DESC_FN_TYPEDEF *descFn)
: libraryPath(path), qutex("SenseApiLib-" + path),
: libraryPath(path), qutex("SenseApiLib-" + path), isBeingDestroyed(false),
dlopen_handle(_dlopen_handle, DlCloser()),
SMO_GET_SENSE_API_DESC_FN_NAME(descFn)
{}
@@ -50,6 +51,7 @@ public:
public:
std::string libraryPath;
Qutex qutex;
std::atomic<bool> isBeingDestroyed;
std::unique_ptr<void, DlCloser> dlopen_handle;
/* UNIMPLEMENTED: API-specific cmdline options. These affect this specific
* sense api lib's behaviour globally.