From c8549e41daeead45971c9a89047635d2e4dbfdbe Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 21 Sep 2018 15:58:14 -0400 Subject: [PATCH] touch the zms lock file every hour so that we can determine which ones are stale --- src/zm_eventstream.cpp | 6 ++++++ src/zm_monitorstream.cpp | 6 ++++++ src/zm_stream.cpp | 2 ++ src/zm_stream.h | 1 + 4 files changed, 15 insertions(+) diff --git a/src/zm_eventstream.cpp b/src/zm_eventstream.cpp index 2578d91d4..026d0f9f6 100644 --- a/src/zm_eventstream.cpp +++ b/src/zm_eventstream.cpp @@ -755,6 +755,12 @@ void EventStream::runStream() { // commands may set send_frame to true while(checkCommandQueue()); + // Update modified time of the socket .lock file so that we can tell which ones are stale. + if ( now.tv_sec - last_comm_update.tv_sec > 3600 ) { + touch(sock_path_lock); + last_comm_update = now; + } + if ( step != 0 ) curr_frame_id += step; diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 48d83200c..1a9540682 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -531,6 +531,12 @@ void MonitorStream::runStream() { Debug(2, "Have checking command Queue for connkey: %d", connkey ); got_command = true; } + // Update modified time of the socket .lock file so that we can tell which ones are stale. + if ( now.tv_sec - last_comm_update.tv_sec > 3600 ) { + touch(sock_path_lock); + last_comm_update = now; + } + } if ( paused ) { diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index f911f2c78..eccb6baf7 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -313,6 +313,8 @@ void StreamBase::openComms() { snprintf(rem_sock_path, sizeof(rem_sock_path), "%s/zms-%06dw.sock", staticConfig.PATH_SOCKS.c_str(), connkey); strncpy(rem_addr.sun_path, rem_sock_path, sizeof(rem_addr.sun_path)-1); rem_addr.sun_family = AF_UNIX; + + gettimeofday(&last_comm_update, NULL); } // end if connKey > 0 Debug(2, "comms open"); } // end void StreamBase::openComms() diff --git a/src/zm_stream.h b/src/zm_stream.h index 4e8343b8c..f9364bbef 100644 --- a/src/zm_stream.h +++ b/src/zm_stream.h @@ -85,6 +85,7 @@ protected: int step; struct timeval now; + struct timeval last_comm_update; double base_fps; double effective_fps;