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.
  • Loading branch information
Paul Harrison committed Oct 21, 2012
1 parent 3b495e9 commit 52b2773
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mythplugins/mythzoneminder/mythzmserver/zmserver.cpp
Expand Up @@ -1380,7 +1380,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 @@ -1391,6 +1391,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 52b2773

Please sign in to comment.