Permalink
Browse files

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 52b2773)

Signed-off-by: Paul Harrison <pharrison@mythtv.org>
  • Loading branch information...
1 parent 6e0f69d commit d2127813712612699a490a50476166ce062f166e Paul Harrison committed Oct 21, 2012
Showing with 16 additions and 1 deletion.
  1. +16 −1 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)

0 comments on commit d212781

Please sign in to comment.