VirtualBox

Changeset 10391 in vbox for trunk/src


Ignore:
Timestamp:
Jul 8, 2008 10:19:04 PM (17 years ago)
Author:
vboxsync
Message:

Override IOService::terminate to prevent a busy VBoxDrv from being half unloaded and crash the system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r10389 r10391  
    108108    virtual void stop(IOService *pProvider);
    109109    virtual IOService *probe(IOService *pProvider, SInt32 *pi32Score);
     110    virtual bool terminate(IOOptionBits fOptions);
    110111};
    111112
     
    196197/** Calculates the index into g_apSessionHashTab.*/
    197198#define SESSION_HASH(pid)     ((pid) % RT_ELEMENTS(g_apSessionHashTab))
     199/** The number of open sessions. */
     200static int32_t volatile g_cSessions = 0;
    198201
    199202
     
    202205 * rest of the kernel modules on darwin.
    203206 */
    204 extern PFNRT g_apfnVBoxDrvIPRTDeps[] =
     207PFNRT g_apfnVBoxDrvIPRTDeps[] =
    205208{
    206209    (PFNRT)RTUuidCompare,
     
    352355        pSession->pNextHash = g_apSessionHashTab[iHash];
    353356        g_apSessionHashTab[iHash] = pSession;
     357        ASMAtomicIncS32(&g_cSessions);
    354358        RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
    355359    }
     
    387391            g_apSessionHashTab[iHash] = pSession->pNextHash;
    388392            pSession->pNextHash = NULL;
     393            ASMAtomicIncS32(&g_cSessions);
    389394        }
    390395        else
     
    398403                    pPrev->pNextHash = pSession->pNextHash;
    399404                    pSession->pNextHash = NULL;
     405                    ASMAtomicIncS32(&g_cSessions);
    400406                    break;
    401407                }
     
    827833    dprintf(("org_virtualbox_SupDrv::stop([%p], %p)\n", this, pProvider));
    828834    IOService::stop(pProvider);
     835}
     836
     837
     838/**
     839 * Termination request.
     840 *
     841 * @return  true if we're ok with shutting down now, false if we're not.
     842 * @param   fOptions        Flags.
     843 */
     844bool org_virtualbox_SupDrv::terminate(IOOptionBits fOptions)
     845{
     846    bool fRc;
     847    dprintf(("org_virtualbox_SupDrv::terminate: reference_count=%d g_cSessions=%d\n",
     848             KMOD_INFO_NAME.reference_count, ASMAtomicUoReadS32(&g_cSessions)));
     849    if (    KMOD_INFO_NAME.reference_count != 0
     850        ||  ASMAtomicUoReadS32(&g_cSessions))
     851        fRc = false;
     852    else
     853        fRc = IOService::terminate(fOptions);
     854    dprintf(("org_virtualbox_SupDrv::terminate: returns %d\n", fRc));
     855    return fRc;
    829856}
    830857
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