From d2127813712612699a490a50476166ce062f166e Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Sun, 21 Oct 2012 11:09:17 +0100 Subject: [PATCH] mythzmserver: Add a proper check for a failed call to mmap() Should be checking for MAP_FAILED not NULL. Also add some additional debugging showing why we failed to open the mmap file. Fixes #11187. (cherry picked from commit 52b277397431dd88a337e46a7d64fea89c8037c0) Signed-off-by: Paul Harrison --- .../mythzoneminder/mythzmserver/zmserver.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mythplugins/mythzoneminder/mythzmserver/zmserver.cpp b/mythplugins/mythzoneminder/mythzmserver/zmserver.cpp index 9b2ee8a0e26..c6cbaecd6b5 100644 --- a/mythplugins/mythzoneminder/mythzmserver/zmserver.cpp +++ b/mythplugins/mythzoneminder/mythzmserver/zmserver.cpp @@ -1385,7 +1385,7 @@ void ZMServer::initMonitor(MONITOR *monitor) shm_ptr = mmap(NULL, shared_data_size, PROT_READ, MAP_SHARED, mapFile, 0x0); - if (shm_ptr == NULL) + if (shm_ptr == MAP_FAILED) { cout << "Failed to map shared memory from file [" << mmap_filename << "] " << @@ -1396,6 +1396,21 @@ void ZMServer::initMonitor(MONITOR *monitor) return; } } + else + { + // this is not necessarily a problem, maybe the user is still + // using the legacy shared memory support + if (m_debug) + { + cout << "Failed to open mmap file [" << + mmap_filename << "] " << + "for monitor: " << + monitor->mon_id << + " : " << strerror(errno) << + endl; + cout << "Falling back to the legacy shared memory method" << endl; + } + } #endif if (shm_ptr == NULL)