Repository navigation
Conversation
Event::Close() (zmeventtool.pl close) took the end of an event only from its Frames rows and refused events that had none. zmc writes Frames rows in batches and updates the event row's Length, Frames and scores with each batch, so an event whose zmc was killed in its first seconds has no Frames rows, and either side can be ahead of the other. Take Length, Frames, AlarmFrames, TotScore and MaxScore as the larger of the event row and the Frames rows; EndDateTime follows the Length that was used. The name and Notes are written as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An event open when its zmc is killed (lost stop, OOM, crash) keeps EndDateTime NULL. Nothing closes it on a default install: zmaudit only does with ZM_RUN_AUDIT on and after ZM_AUDIT_MIN_AGE, and the next zmc does not look at earlier events. A running zmc closes its event before it reconnects and sets startup_time in shared memory after it connects, so an open event of its monitor that started before that time belongs to a process that is gone. Once per zmc start, when its heartbeat is fresh, zmwatch closes those events through Event::Close(). Only this server's monitors are checked, and re-analysis events (Cause 'Re-analysis', created by zma with their original times) are left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
connortechnology
left a comment
Member
There was a problem hiding this comment.
Close() always renames the event to <prefix><Id>(r), so it overwrites a name the user gave the event while it was recording. That was fine while only zmeventtool.pl close and zmaudit called it, by hand or a day later, but now zmwatch runs it on its own every time a zmc restarts.
zmc's own close only renames an event whose name is still the placeholder (~Event() in src/zm_event.cpp):
Name = IF(Name='New Event', '<prefix><Id>', Name)Could Close() do the same here: add the (r) name only when Name is still New Event, and otherwise keep the user's name? The Recovered. note still marks the event either way. I'd fold this into this PR rather than leave it as a follow-up, since this is the change that makes the rename automatic.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Event::Close()(also behindzmeventtool.pl close) now works when the event has no Frames rows yet. 3 files, +179/-9 (120 of them a Perl test).Details: change, behaviour changes, checks
Before
Upstream master
821030e17:kill -9a Recording=Always zmc mid-event. The event keepsEndDateTimeNULL indefinitely:Change
scripts/zmwatch.pl.in: when a monitor's heartbeat is fresh and its shared-memorystartup_timediffers from the last one seen, close its events withEndDateTime IS NULL,StartDateTime < FROM_UNIXTIME(startup_time)and Cause other thanRe-analysis, throughEvent::Close(). A running zmc closes its event before reconnecting and setsstartup_timeafter connecting, so it never owns such an event. Only this server's monitors.scripts/ZoneMinder/lib/ZoneMinder/Event.pmClose(): Length, Frames, AlarmFrames, TotScore and MaxScore = the larger of the event row and the Frames rows (zmc writes both in batches, so either can be ahead); EndDateTime follows the Length used; works with no Frames rows; refuses an event without a start. Name and Notes as before ((r)andRecovered., zmaudit's existing tags).tests/perl/test_event_close_recovered.pl(17 cases; 11 fail on master'sEvent.pm).Behaviour changes
<prefix><Id>(r), noteRecovered.isEventEnded()now sees them endEvent::Close()Closed event N on monitor M …zmeventtool.pl closehandles events with no Frames rowsAfter
Branch at
993b0d80d(base821030e17).kill -9of monitor 2's zmc at 00:01:38; event 60 closed 13 s later, the new zmc's event 61 untouched:Not run: clients (no API change), multi-server, release-1.38 (backport prepared, not run).
Possible follow-ups
Offered for discussion, not part of this change:
index.m3u8has no#EXT-X-ENDLIST, so some players treat it as live. Rewriting it as VOD would fix that. Risk: file rewrites in event directories.zmeventtool close. Risk: a naming change for admins who rely on the(r)suffix.A branch with the first three exists and was lab-tested; happy to open it separately if wanted.
refs #5200
🤖 Generated with Claude Code