Actually use zmc_heartbeat_time. Set it on every capture and use it in ShmValid to determine if zmc has gone away.

This commit is contained in:
Isaac Connor 2021-03-08 09:30:53 -05:00
parent 920556e002
commit e38e8a2775
2 changed files with 4 additions and 1 deletions

View File

@ -2505,6 +2505,7 @@ int Monitor::Capture() {
packet->timestamp = new struct timeval;
packet->image_index = image_count;
gettimeofday(packet->timestamp, nullptr);
shared_data->zmc_heartbeat_time = packet->timestamp->tv_sec;
Image* capture_image = image_buffer[index].image;
int captureResult = 0;

View File

@ -410,7 +410,9 @@ public:
bool disconnect();
inline int ShmValid() const {
return shared_data && shared_data->valid;
struct timeval now;
gettimeofday(&now, nullptr);
return shared_data && shared_data->valid && ((now.tv_sec - shared_data->zmc_heartbeat_time) > config.watch_max_delay);
}