Skip to content

Commit

Permalink
mythzmserver: Add a proper check for a failed call to mmap()
Browse files Browse the repository at this point in the history
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
Paul Harrison committed Mar 20, 2013
1 parent 6e0f69d commit d212781
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mythplugins/mythzoneminder/mythzmserver/zmserver.cpp
Expand Up @@ -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 << "] " <<
Expand All @@ -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)
Expand Down

0 comments on commit d212781

Please sign in to comment.