Ticket #11187: 0001-mythzmserver-Add-a-proper-check-for-a-failed-call-to.patch

File 0001-mythzmserver-Add-a-proper-check-for-a-failed-call-to.patch, 1.8 KB (added by anonymous, 12 years ago)
  • mythplugins/mythzoneminder/mythzmserver/zmserver.cpp

    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) 
    13801380
    13811381        shm_ptr = mmap(NULL, shared_data_size, PROT_READ,
    13821382                                            MAP_SHARED, mapFile, 0x0);
    1383         if (shm_ptr == NULL)
     1383        if (shm_ptr == MAP_FAILED)
    13841384        {
    13851385            cout << "Failed to map shared memory from file [" <<
    13861386                mmap_filename << "] " <<
    void ZMServer::initMonitor(MONITOR *monitor) 
    13911391            return;
    13921392        }
    13931393    }
     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    }
    13941409#endif
    13951410
    13961411    if (shm_ptr == NULL)