fix: unmap the old shared memory when zm_rtsp_server reconnects to a restarted zmc refs #5886

This commit is contained in:
Jash committed 2026-11-14 21:52:57 +05:30
1 parent 697aa897be
commit c14f77b309
1 file changed
+8 -2
+8 -2
View File
@@ -455,9 +455,15 @@ int main(int argc, char *argv[]) {
if (stream.HasClients()) {
// The shm connection is only needed for viewer accounting now
if (monitor->ShmValid() or monitor->connect()) {
monitor->setLastViewed(std::chrono::system_clock::now());
if (!monitor->ShmValid()) {
// zmc restarted: unmap its old shared memory instead of leaking it
monitor->disconnect();
if (!monitor->connect()) {
Debug(1, "Monitor %d shared memory not available yet, retrying next pass", monitor->Id());
continue;
}
}
monitor->setLastViewed(std::chrono::system_clock::now());
}
} // end foreach monitor