VirtualBox

Ignore:
Timestamp:
Sep 8, 2015 10:19:37 AM (9 years ago)
Author:
vboxsync
Message:

Main/HostPowerLinux: fix a potential crash on exit, e.g. during debugging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/linux/HostPowerLinux.cpp

    r57642 r57653  
    8585HostPowerServiceLinux::~HostPowerServiceLinux()
    8686{
     87    int rc;
     88    RTMSINTERVAL cMillies = 5000;
     89
    8790    /* Closing the connection should cause the event loop to exit. */
    8891    LogFunc((": Stopping thread\n"));
     
    9093        dbus_connection_close(mpConnection);
    9194
    92     RTThreadWait(mThread, 5000, NULL);
     95    rc = RTThreadWait(mThread, cMillies, NULL);
     96    if (rc != VINF_SUCCESS)
     97        LogRelThisFunc(("RTThreadWait() for %u ms failed with %Rrc\n", cMillies, rc));
    9398    mThread = NIL_RTTHREAD;
    9499}
     
    99104    NOREF(hThreadSelf);
    100105    HostPowerServiceLinux *pPowerObj = static_cast<HostPowerServiceLinux *>(pInstance);
     106    DBusConnection *pConnection = pPowerObj->mpConnection;
    101107
    102108    Log(("HostPowerServiceLinux: Thread started\n"));
    103     while (dbus_connection_read_write(pPowerObj->mpConnection, -1))
     109    while (dbus_connection_read_write(pConnection, -1))
    104110    {
    105111        DBusMessage *pMessage = NULL;
     
    110116            dbus_bool_t fSuspend;
    111117
    112             pMessage = dbus_connection_pop_message(pPowerObj->mpConnection);
     118            pMessage = dbus_connection_pop_message(pConnection);
    113119            if (pMessage == NULL)
    114120                break;
     
    140146    }
    141147    /* Close the socket or whatever underlying the connection. */
    142     dbus_connection_close(pPowerObj->mpConnection);
     148    dbus_connection_close(pConnection);
    143149    /* Free in-process resources used for the now-closed connection. */
    144     dbus_connection_unref(pPowerObj->mpConnection);
    145     pPowerObj->mpConnection = NULL;
     150    dbus_connection_unref(pConnection);
    146151    Log(("HostPowerServiceLinux: Exiting thread\n"));
    147152    return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette