Ticket #5124: libs_libmythtv_linuxfirewiredevice.cpp-check-pthread_create.patch

File libs_libmythtv_linuxfirewiredevice.cpp-check-pthread_create.patch, 1.3 KB (added by Erik Hovland <erik@…>, 12 years ago)

check pthread_create and report on failure

  • libs/libmythtv/linuxfirewiredevice.cpp

    pthread_create returns a value. It should be checked.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythtv/linuxfirewiredevice.cpp |   18 ++++++++++++++++--
     1 files changed, 16 insertions(+), 2 deletions(-)
    
    diff --git a/libs/libmythtv/linuxfirewiredevice.cpp b/libs/libmythtv/linuxfirewiredevice.cpp
    index ea826aa..344dc73 100644
    a b bool LinuxFirewireDevice::OpenPort(void) 
    277277    }
    278278
    279279    VERBOSE(VB_RECORD, LOC + "Starting port handler thread");
     280    int rval = pthread_create(&m_priv->port_handler_thread, NULL,
     281                              linux_firewire_device_port_handler_thunk, this);
     282    if (rval != 0)
     283    {
     284        VERBOSE(VB_IMPORTANT,
     285                LOC_ERR
     286                + QString("Failed to create port handler thread with error %1")
     287                  .arg(strerror(rval)));
     288
     289        m_lock.unlock();
     290        ClosePort();
     291        m_lock.lock();
     292
     293        return false;
     294    }
     295
    280296    m_priv->run_port_handler = true;
    281     pthread_create(&m_priv->port_handler_thread, NULL,
    282                    linux_firewire_device_port_handler_thunk, this);
    283297
    284298    VERBOSE(VB_RECORD, LOC + "Waiting for port handler thread to start");
    285299    while (!m_priv->is_port_handler_running)