- kernelEventFilterYOLO declared m_fThreadProc() but never defined it:
the link failed with "undefined reference to vtable for
kernelEventFilterYOLO". Added a placeholder worker loop (same style
as the Bubble filter) until the YOLO processing is implemented.
- m_sYOLOFilterData is zero-initialised (validate() memcmp's it).
- Silenced the new unused-parameter warnings: validateTarget /
dispatchEvent stubs and dataBinder::getYOLOFilterData (the latter
warned in every file that includes dataBinder.h).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Leaks that grew without bound:
- Dead module connections were never removed (half-open TCP after a
module power loss / network drop): every one kept 3 threads, 8 MB of
socket buffers, a descriptor and a 10 ms DB poll. servaRPCHadnler now
drops a connection that sends nothing for RPC_IDLE_TIMEOUT_S (60 s;
la_mojo sends a status about every second), and accepted sockets get
TCP keepalive (30 s idle, 3 probes of 10 s).
- The client socket was only closed on an I/O error: a handler removed
for any other reason (module disabled / not registered, idle) leaked
its descriptor until accept() failed with EMFILE - which ended the
accept thread for good. ~serverPort now shuts down and closes it;
transient accept() errors (EMFILE, ENFILE, ENOMEM, ECONNABORTED,
EINTR, ...) no longer stop the server. recv() == 0 (peer closed) is
always a disconnect, whatever errno holds.
- servaSessionManager::reopenSession stored the reopened (expired)
session in the per-track map, overwriting the track's ACTIVE session:
its data and open report.db leaked and it was never closed in MySQL.
Reopened sessions are now kept outside the map and released by the
caller (addVideo, getSessionBase).
- servaVideoComposer leaked its session data, an open SQLite connection
and both video queues on every composition; servaKernel leaked a
composer whose compose() failed, never initialised / released the
automatic composer (it ran at most once) and leaked the media info
of every encoded video (processVideoFile success path).
Crashes / corruption:
- vector erase() with the old iterator reused (netServer client
cleanup, encoder / composer pools, 4 ModBus action loops).
- transportSocket::_close wrote the stop byte into the read end of the
pipe (threads only stopped at the 5 s select timeout, blocking the
accept thread on every disconnect) and left closed pipe numbers set
(a second _close could write into another connection's socket).
- Session map used without the lock from RPC, kernel and ModBus
threads: now a recursive mutex held for each public operation.
- Freeze on the first MySQL error with DB logging enabled: Query() logs
while holding the non-recursive DB mutex and the log service wrote
synchronously into the DB (same-thread and two-thread deadlock).
The DB log service now queues lines (max 1000) and writes them with
MySQL_Connector::TrySilentQuery (never blocks, never logs); reconnect
retries per query are bounded (3) instead of looping forever while
holding the mutex. The log line parser also skips the UTC offset.
- basicMutex::try_lock returned true when the lock was NOT taken: an
uncontended try_lock took the mutex and the caller never released it
(basicEngine, serial transport, ...).
- Kernel restart (web commands): the ModBus singleton was deleted but
not reset (next getInstance returned freed memory), the remote client
kept the deleted kernel and refused to start again, and
EXIT_CODE_RELOAD_SERVICES deleted the DB object every surviving
component still used. Now fixed / the DB object is kept.
- Life monitoring overflowed module_id[4] for platforms with > 4
modules; registerServA overflowed a 120-byte stack buffer, closed a
popen() stream with fclose and leaked the config; 9 config strings in
servaBackend were allocated one byte short; video chunk length is now
checked against the packet; "eased" events copied every field from
itself (all 0); networkServer freed libconfig's host string.
Minor: ModBus action list / sessions freed at shutdown, session-start
event payload freed if the event cannot be created, the per-second
"No History Auto Delete!" log line moved to DEBUG_EXTRA.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
PTZ health per camera (deviceNodeCamera):
- PTZ_HEALTH_INFO: state (NONE / INIT / OK / FAILED), failure and
recovery counters, consecutive failed initialisations, time of the
last state change / failure, next retry and the last error text.
getPtzHealth() returns a copy (mutex-protected, any thread).
- getPtzStatus() - already sent to the remote server as
CAMERA_STATUS_PTZ_OK - now reflects it: 1 for OK (or no PTZ protocol),
0 while PTZ is initialising or failed. Before it was 1 as soon as the
state machine left CAM_WS_INIT, whatever the protocol did.
Failure detection and re-initialisation:
- While idle (CAM_WS_READY) the camera checks the protocol's validate()
every loop and calls the new protocolPTZ::probe() every 30 s
(ONVIF: GetStatus; a SOAP Fault still means "reachable", only a
communication error marks the camera lost). Default probe() is the
protocol's validate(), so serial protocols are unchanged.
- On failure the PTZ protocol is recreated through CAM_WS_INIT: first
attempt at once, then 5, 10, 20, 40, 60 s (capped) between attempts;
recoveries are logged and counted.
- A failed target-driven goAbsolute/goPreset no longer ends the camera
thread (CAM_WS_END rebuilt the whole node): for ONVIF a command the
camera rejected (connection OK) only drops that ROI, anything else
re-initialises the PTZ protocol.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
1. Faults are no longer reported as success: every request waits for the
answer, checks the HTTP status and the SOAP Fault (logged with
Code/Subcode/Reason); getLastError()/getLastFault() tell the caller.
protocolPTZ_ONVIF clears m_bStatus (-> reconnect) only on
communication errors, not on a Fault from a reachable camera.
AbsoluteMove now waits for its answer too.
2. Request/reply race: already fixed in #11 (checked).
3. NULL-safe parsing of optional elements (safeCopy/safeAtoi/safeAtof),
videoSource zero-filled, Imaging values parsed as float, IrCutFilter
AUTO no longer read as OFF, missing XAddr no longer becomes "(null)",
GetSystemDateAndTime without UTCDateTime no longer breaks the token
time (falls back to the local clock).
4. GetProfiles parses PTZConfiguration; the PTZ profile is the first one
that has it (fallback to profile 0 with an error log); create() fails
cleanly when the device has no profiles instead of throwing.
5. Pan/tilt and zoom in one ContinuousMove with Timeout PT10S
(PONVIF_CONTINUOUS_MOVE_TIMEOUT_S); Stop honours its pantilt/zoom flags.
6. WS-Security: 16-byte RAND_bytes nonce, no fixed-size digest buffer,
header only when a user name is set (anonymous devices), user name and
all string arguments XML-escaped. Requests are built by _buildRequest()
from body templates. HTTP auth mode 0 now uses CURLAUTH_ANY (sends no
password until the device asks; Digest preferred) instead of Basic;
no HTTP auth without credentials.
Also: Content-Type without the trailing ';', GetServices/
GetDeviceInformation sent to the device service, printf format-string
bugs on device replies fixed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Target-driven moves of deviceNodePTZCamControl (AbsoluteMove) and
deviceNodePresetCamControl (preset for the ROI) both end in
CAM_WS_WAIT_ONPOS, which waits for the end of the move and then
broadcasts EVT_CAMERA_ON_POSITION (EVT_CLASS_CAMERA_CTRL).
- AbsoluteMove: with video output enabled (m_bSkeepPositioningWait) the
event was broadcast right after the command, before the camera moved.
It now always goes through CAM_WS_WAIT_ONPOS, like the preset path.
- New m_bNoMoveDoneReport: set when the protocol cannot report the end
of a move (waitMoveIsDone() returns false). Then a fixed
CAM_MOVE_FIXED_WAIT_MS (3 s) wait is used before the event. Before, the
same failure set m_bSkeepPositioningWait, which made every later
AbsoluteMove broadcast the event immediately. Reset when the protocol
is (re)created.
- protocolPTZ_ONVIF::goPreset: forget the last AbsoluteMove target so
waitMoveIsDone() cannot end early by comparing with it.
Homing, init go-home and web/IR/wiper presets are unchanged (no event).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
waitMoveIsDone() used to poll GetStatus for at most ~4 s and only
understood MoveStatus. Cameras that report only the position (or report
MoveStatus only away from 0/0/0) always ran into the timeout.
- After create(), protocolPTZ_ONVIF detects what the camera reports:
PTZ GetServiceCapabilities (MoveStatus / StatusPosition attributes)
plus a real GetStatus probe. The result is logged
("PTZ status support: ...").
- waitMoveIsDone():
* MoveStatus cameras: poll every 200 ms until pan/tilt and zoom are
IDLE (IDLE right after the command is ignored for 1 s unless the
camera was seen MOVING or is already on target);
* position-only cameras: until the AbsoluteMove target is reached or
the position stops changing;
* cameras reporting neither: fixed 3 s wait.
Gives up after 10 s, falls back to the fixed wait after 3 failed
GetStatus calls.
- pOnvif::ptz_GetStatus: Position and MoveStatus are optional in the
schema; read every element NULL-safe, always read MoveStatus, report
hasPosition / hasZoomPosition / isMoving.
- pOnvif::_send_request: arm the reply flag before queuing the request
and ignore late replies of timed-out requests, so a poll can no longer
get the answer of the previous request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
The report engine now keeps a separate SQLite database for every local
hour inside the day folder:
data/reports/YYYY/MM/DD/report_HH.db (REPORT_DB_NAME_FMT "report_%02d.db")
Pictures and videos stay in the day folder; the stat.db day records are
unchanged.
- sqliteDBC::openHourReport(): opens/creates report_HH.db of the given day
and hour (replaces openDayReport); switchReportToCurrentHour() (renamed
from switchReportToCurrentDay) switches when the local day or hour
changes. connect() opens the current hour's file at startup.
- mojoKernel::handleReportPeriodChange() (was handleDayChange): runs the
same close-then-switch sequence every local hour: an open session that
started in the previous hour is closed in the old file (waiting at most
REPORT_SWITCH_MAX_VIDEO_WAIT for a recording with events), then the
report switches to the new hour; the next event opens a new session.
Each hourly file therefore contains complete sessions.
- getLocalHour() helper in basicFunctionality.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Before, the report (data/reports/YYYY/MM/DD/report.db, plus pictures and
videos stored next to it) only moved to a new day inside
updateStats(SESSION_START) - and that branch never ran, because
updateStats() skipped every call with evt=false/video=false, which is how
all session status changes are reported. So the report only changed day
when the process restarted; everything after midnight went into the
previous day's report.
- mojoKernel::handleDayChange() (every second from validateReports):
at local midnight an open session that started on the previous day is
closed (END event goes into the old report). If a video segment with
events is still recording, wait for it at most DAY_CHANGE_MAX_VIDEO_WAIT
(90 s) so the video is stored next to its events. After the END event is
written, the report is switched to the new day. The next event starts a
new session in the new day's report.
- sqliteDBC::switchReportToCurrentDay() / openDayReport(): opens (creates)
the current local day's report directory and database, retried until it
succeeds. Report state is protected by a recursive mutex because the
switch runs on the kernel thread while events are written on the event
thread.
- updateStats(): no longer drops SESSION_START/END/DROP calls, so the
session counters in stat.db are updated and SESSION_START also switches
the report if needed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Timestamps are now formatted with strftime("%Y-%m-%d %H:%M:%S%z"), e.g.
"2026-11-26 12:14:55+0200", so log lines are unambiguous across time
zones and daylight-saving changes. Applies to all log modes that include
time (_LOG_TIME, _LOG_TIME_PTR, _LOG_LVL_TIME, _LOG_LVL_TIME_PTR); the rest
of the line format is unchanged. In GMT mode the offset is +0000.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16