Commit Graph

160 Commits

Author SHA1 Message Date
hayodea d75430ef82 Qutex: Document the need to deal with early release()s 2025-09-30 21:25:58 -04:00
hayodea 06f3f2eebe DevMgr:attachAllUnattachedDevicesFromKnownListReq: acquire qutex
We should acquire the qutex here before iterating through the list
of DA specs.
2025-09-30 21:24:51 -04:00
hayodea 07609c6d6c 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.
2025-09-30 21:01:00 -04:00
hayodea 1bad358921 DevMgr:at/detachSenseDevReq: release SenseApiMgr Qutex early
Release it early when we no longer need it.
2025-09-30 20:29:39 -04:00
hayodea 77e123ff4a DevMgr:at/detachSenseDevReq: acquire SenseApiMgr qutex 2025-09-30 19:53:57 -04:00
hayodea 9c3a8ea695 Indentation 2025-09-30 19:51:50 -04:00
hayodea 0ff86a0a5e SenseApiMgr: Add Qutex 2025-09-30 19:51:01 -04:00
hayodea 8ad5179a61 DevMgr:at/detachSenseDevReq: only acquire API lib lock
We don't actually manipulate any of SenseApiMgr or DevMgr's state
so there's no need to acquire their locks.
2025-09-30 19:47:23 -04:00
hayodea e600b0f96e DevMgr:at/detachSenseDevReq: acquire Api lib Qutex 2025-09-30 18:12:20 -04:00
hayodea b0d61c3e38 DevMgr:at/detachSenseDevReq: Acquire DevMgr Qutex 2025-09-30 14:22:51 -04:00
hayodea ccf0ab77bf Move SerializedAsyncContin template method impls into header 2025-09-30 13:59:07 -04:00
hayodea 33b61f429a LockSet: Move method impls into template header 2025-09-30 13:42:13 -04:00
hayodea 7ded9d287d Split comment into relevant locations 2025-09-30 13:27:06 -04:00
hayodea f15c07bc83 LockSet:tryAcquireOrBackoff use optional<ref_wrapper<Qutex>>
Replace the previous Qutex** raw pointer with a std::optional.
2025-09-30 10:36:19 -04:00
hayodea e299e956e5 Move LockSet::release into header 2025-09-30 03:01:13 -04:00
hayodea ca9eae197f Lockvoker: Add registerInLockSet
We now create the sh_ptr to the copy of a lockvoker object in its
own supplied register method. This enables us to retain type safety
when calling make_shared, by copying the most derived version of
the lockvoker object. Then we can pass in the LockerAndInvokerBase
to the rest of the call chain.
2025-09-30 02:55:25 -04:00
hayodea 08122c086c LockSet:tryAcquireOrBackoff: should take Qutex**, not Qutex*
No idea how this error survived in here for so long.
2025-09-30 02:53:54 -04:00
hayodea cb8b13d0cd LockSet:release() Remove superfluous Lockvoker arg
We decoupled unregistration from release() so we no longer need
to pass in a lockvoker to release().
2025-09-30 02:17:46 -04:00
hayodea 97d93c670e Indentation 2025-09-30 01:15:30 -04:00
hayodea 9d77e8b345 SenseApiLib: Add qutex for lib state access serialization 2025-09-30 01:14:00 -04:00
hayodea 4bf19fda90 Get rid of rvalue ref returns 2025-09-30 00:37:54 -04:00
hayodea ed9635582f Lockvoker: add handleGridlock and invoke it 2025-09-30 00:32:54 -04:00
hayodea d06ba8957a QtxAcqHistTracker: Implement complete algo; add depend graph
The dependency graph class enables us to perform analysis on the
qutex acquisition history data. By generating the graph and
detecting cycles in it, we can find true gridlocks.

We use this graph analysis code to implement the algorithmically
complete version of the gridlock detector.
2025-09-30 00:24:33 -04:00
hayodea 1aec779351 CMake: Conditionally build QtxAcquisitionHistTracker 2025-09-29 21:09:31 -04:00
hayodea 6baa0bb008 Silence build warning 2025-09-29 20:48:49 -04:00
hayodea 274edc1013 QtxHistTracker: Print message on heuristic gridlock find 2025-09-29 20:47:04 -04:00
hayodea c0eecf76d4 QtxAcqHistTracker: Add spinlock and use it 2025-09-29 20:34:56 -04:00
hayodea 2390042892 QtxAcqHistTracker: implement heuristic gridlock detector 2025-09-29 20:02:23 -04:00
hayodea 5c7a92b3a4 SerializedAsyncContin:getAcquiredQutexHistory returns rval ref
This ensures that the caller takes ownership.
2025-09-29 19:40:51 -04:00
hayodea 71564b4d83 Add QutexAcquisitionHistoryTracker; integrate plumbing
We add the new Qutex acquisision history tracker that allows us
to dynamically detect qutex gridlocks. We've integrated it into
LockerAndInvoker::operator() in a preliminary way.

We also moved all of the trace*ForGridlockOn() methods into the
new QutexAcquisitionHistoryTracker singleton class. They're
more appropriately located there. They're still unimplemented
though.
2025-09-29 19:27:02 -04:00
hayodea 8123ec1227 Qutex: Deprecate old gridlock trace; add skeleton new trace
We add the skeleton of a correct history tracer for gridlocks. The
previous history tracer made the incorrect assumption that we would
find the foreign sequence's currently desired LockSet inside of the
lockvoker that it has stored inside of Qutex::currOwner.
2025-09-29 18:14:10 -04:00
hayodea 2a60fdd9df Qutex: currOwner should use registered sh_ptr to Lockvoker
This ensures that the Lockvoker object we access from currOwner
remains valid past the lifetime of the Lockvoker object that
gets copied and invoked by boost::asio
2025-09-29 14:37:16 -04:00
hayodea 462247d743 Qutex: Add gridlock detection 2025-09-29 13:38:53 -04:00
hayodea 6b4fe05fc0 Qutex: Add gridlock detection wireframing
This is the basic wireframing required to enable us to detect
gridlocks among requests.
2025-09-29 12:58:41 -04:00
hayodea 7e514a1fa3 Qutex: Add currOwner pointer for debugging
We'll use this to detect gridlock-type deadlocks between
two requests
2025-09-29 12:40:43 -04:00
hayodea 542e3081ad DevReattacher: Use aggregate init for Callback<> 2025-09-29 01:59:52 -04:00
hayodea cea65dcd00 Mrntt: Call initializeDeviceReattacher in init
It works surprisingly well on the first try.
2025-09-29 01:07:32 -04:00
hayodea 6cebf6856e Indentation 2025-09-28 23:35:20 -04:00
hayodea 20d568a063 DevMgr: Call attachAll*FromKnownListReq in DeviceReattacher
Well, I guess now we have auto-reattaching devices.
2025-09-28 23:34:39 -04:00
hayodea bd52e49ba3 DevMgr: Add attachAllUnattachedDevicesFromKnownListReq
This function is the backbone for the DeviceReattacher daemon. It
assembles a list of all DA specs which are known to Mrntt, but which
haven't been successfully attached as yet, and attempts to attach
them.
2025-09-28 23:15:22 -04:00
hayodea 93103aa8d4 DevMgr: Add DeviceReattacher daemon plumbing
This is the plumbing for a periodic polling thread that tries
to reattach DA specs that failed to attach in the startup phase.
2025-09-28 23:07:39 -04:00
hayodea c0798d1bdb DevMgr: detachAll only detaches from attachedDeviceRoles
We no longer try to detach from the collection of specs. We
detach from the collection of attachedDeviceRoles. This means
our cleanup sequence no longer tries to clean up things that were
never set up to begin with.
2025-09-28 13:04:07 -04:00
hayodea e45a9ee5d1 DAP.yy: use cmdlineDASpecs; DevMgr: add attachAllUnattachedDevicesFromCmdlineReq
This method wraps around attachAllUnattachedDevicesFromReq and supplies
it with a sh_ptr<> collection of all DASpecs parsed by the DAP parser
from the cmdline.

The initialization sequence now correctly initializes all DAP specs
given on the cmdline again.
2025-09-28 12:52:59 -04:00
hayodea b43ffcb677 DevMgr: attachAllUnattachedDevsFrom: now takes sh_ptr<vector<Spec>>
This method now accepts a sh_ptr<vector<DeviceAttachmentSpec>> to
tell it specifically which specs to attempt to attach.

This enables us to implement different frontends that supply it
with collections of devices from different sources (GUI, cmdline,
previously failed-to-attach/hot-removed devices, etc).

SMO temporarily initializes none of the devices from the cmdline
during this commit as we transition to implementing the cmdline
collection frontend.
2025-09-28 12:39:45 -04:00
hayodea 2c60248127 DevMgr: Rename at/detachAll*Req():
We've renamed these now to better reflect what they do.
* attachAllSenseDevicesFromSpecsReq=>attachAllUnattachedDevicesFromReq
* detachAllSenseDevicesReq=>detachAllAttachedDeviceRoles

This is also the first step in changing
attachAllUnattachedDevicesFrom to accept a sh_ptr<> to a collection
of DeviceAttachmentSpecs. This will enable us to unify the underlying
spec attachment logic and just create several front-ends for attaching
specs from multiple sources.
2025-09-28 12:19:56 -04:00
hayodea 993bf568fc DevMgr: implement removeDeviceAttachmentSpecReq
This reverts all state changes made by newDeviceAttachmentSpecInd.
2025-09-28 11:41:20 -04:00
hayodea 27e707a22d DevMgr:newDevAttSpecInd: take ref & not sh_ptr to DASpec
Because NewDevAttSpecInd should be the function that creates the
persistent sh_ptr state within DevMgr.
2025-09-28 11:14:55 -04:00
hayodea 7ab6e7b2c3 Formatting 2025-09-28 11:05:04 -04:00
hayodea 5b2354bfe0 DevMgr:newDevAttSpecInd: creates Device in frontend
There's no reason why we have to only create the Device at the
end if everything succeeds. The Device isn't the same thing as the
DeviceRole.
2025-09-28 10:57:43 -04:00
hayodea 42ab935da6 Reorder operations 2025-09-28 09:19:09 -04:00