Wait until we get a successful shm connect before trying to set StartupTime. fixes crash
parent
3fbb8bdaca
commit
36f45fdbc7
17
src/zmc.cpp
17
src/zmc.cpp
|
@ -238,20 +238,21 @@ int main(int argc, char *argv[]) {
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
for (const std::shared_ptr<Monitor> &monitor : monitors) {
|
for (const std::shared_ptr<Monitor> &monitor : monitors) {
|
||||||
monitor->LoadCamera();
|
|
||||||
|
|
||||||
if (!monitor->connect()) {
|
|
||||||
Warning("Couldn't connect to monitor %d", monitor->Id());
|
|
||||||
}
|
|
||||||
SystemTimePoint now = std::chrono::system_clock::now();
|
|
||||||
monitor->SetStartupTime(now);
|
|
||||||
|
|
||||||
std::string sql = stringtf(
|
std::string sql = stringtf(
|
||||||
"INSERT INTO Monitor_Status (MonitorId,Status,CaptureFPS,AnalysisFPS,CaptureBandwidth)"
|
"INSERT INTO Monitor_Status (MonitorId,Status,CaptureFPS,AnalysisFPS,CaptureBandwidth)"
|
||||||
" VALUES (%u, 'Running',0,0,0) ON DUPLICATE KEY UPDATE Status='Running',CaptureFPS=0,AnalysisFPS=0,CaptureBandwidth=0",
|
" VALUES (%u, 'Running',0,0,0) ON DUPLICATE KEY UPDATE Status='Running',CaptureFPS=0,AnalysisFPS=0,CaptureBandwidth=0",
|
||||||
monitor->Id());
|
monitor->Id());
|
||||||
zmDbDo(sql);
|
zmDbDo(sql);
|
||||||
|
|
||||||
|
monitor->LoadCamera();
|
||||||
|
|
||||||
|
while (!monitor->connect()) {
|
||||||
|
Warning("Couldn't connect to monitor %d", monitor->Id());
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
SystemTimePoint now = std::chrono::system_clock::now();
|
||||||
|
monitor->SetStartupTime(now);
|
||||||
|
|
||||||
if (monitor->StartupDelay() > 0) {
|
if (monitor->StartupDelay() > 0) {
|
||||||
Debug(1, "Doing startup sleep for %ds", monitor->StartupDelay());
|
Debug(1, "Doing startup sleep for %ds", monitor->StartupDelay());
|
||||||
std::this_thread::sleep_for(Seconds(monitor->StartupDelay()));
|
std::this_thread::sleep_for(Seconds(monitor->StartupDelay()));
|
||||||
|
|
Loading…
Reference in New Issue