From 52b277397431dd88a337e46a7d64fea89c8037c0 Mon Sep 17 00:00:00 2001
From: Paul Harrison <pharrison@mythtv.org>
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.
---
.../mythzoneminder/mythzmserver/zmserver.cpp | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/mythplugins/mythzoneminder/mythzmserver/zmserver.cpp b/mythplugins/mythzoneminder/mythzmserver/zmserver.cpp
index ea1aa17..d42ba33 100644
a
|
b
|
void ZMServer::initMonitor(MONITOR *monitor) |
1380 | 1380 | |
1381 | 1381 | shm_ptr = mmap(NULL, shared_data_size, PROT_READ, |
1382 | 1382 | MAP_SHARED, mapFile, 0x0); |
1383 | | if (shm_ptr == NULL) |
| 1383 | if (shm_ptr == MAP_FAILED) |
1384 | 1384 | { |
1385 | 1385 | cout << "Failed to map shared memory from file [" << |
1386 | 1386 | mmap_filename << "] " << |
… |
… |
void ZMServer::initMonitor(MONITOR *monitor) |
1391 | 1391 | return; |
1392 | 1392 | } |
1393 | 1393 | } |
| 1394 | else |
| 1395 | { |
| 1396 | // this is not necessarily a problem, maybe the user is still |
| 1397 | // using the legacy shared memory support |
| 1398 | if (m_debug) |
| 1399 | { |
| 1400 | cout << "Failed to open mmap file [" << |
| 1401 | mmap_filename << "] " << |
| 1402 | "for monitor: " << |
| 1403 | monitor->mon_id << |
| 1404 | " : " << strerror(errno) << |
| 1405 | endl; |
| 1406 | cout << "Falling back to the legacy shared memory method" << endl; |
| 1407 | } |
| 1408 | } |
1394 | 1409 | #endif |
1395 | 1410 | |
1396 | 1411 | if (shm_ptr == NULL) |