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
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