la_mojo nodes and modules: register for events only when fully built #20
Merged
ClaudeAI
merged 1 commits from fix/event-handler-attach-detach into master 28 minutes ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'fix/event-handler-attach-detach'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Summary
Applies the
attachEvents()/detachEvents()pattern from #19 to the la_mojo camera nodes and kernel modules. They now receive events only while fully constructed.Problem
A handler was registered in the
basicEventHandlerconstructor and removed in its destructor:When a node or module was created or deleted while la_mojo runs (for example a node or module reload), the event heap could call
dispatchEvent()on a half-built or half-destroyed object.Changes
deviceNodePTZCamControl,deviceNodePresetCamControl,deviceNodeStaticCamControl):basicEventHandler(false)and callattachEvents()at their end;detachEvents()first, beforestopService().kernelModuleno longer registers in its constructor;kernelModuleFactoryattaches each module right after creating it, beforestartService(). All la_mojo modules are created there;detachEvents()first: USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed video (both variants), modem manager, Bosch, attention cloud and report backupper.basicEventHeap::moveHandlerTop/Bottomno longer register a handler that is not registered. Otherwise an object could end up registered twice onceattachEvents()runs.Sensor nodes are not event handlers and are unchanged. Handlers are still added at the bottom of the list at almost the same moment, so the dispatch order is unchanged.
Testing
make -kand link. Only the three live555 files cannot compile in the build container, as before. One of them iskernelModuleEmbedVideo.cpp; its two one-line destructor edits were reviewed by hand.Notes
kernelModuleFactoryreceives no events untilattachEvents()is called on it.kernelEventFilterBubble,kernelEventFilterYOLOand the kernel keep the automatic registration. They are not deleted while la_mojo runs, and #19 pauses the heap before shutdown.Generated with Claude Code
https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
d5e172fc4b.