VirtualBox

Changeset 78915 in vbox


Ignore:
Timestamp:
Jun 1, 2019 5:37:37 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131035
Message:

Main/src-client,Main/include: Unregister HGCM service extensions on shutdown instead of leaking the handle

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r78897 r78915  
    6969#ifdef VBOX_WITH_GUEST_PROPS
    7070# include <VBox/HostServices/GuestPropertySvc.h>  /* For the property notification callback */
     71#endif
     72
     73#if    defined(VBOX_WITH_GUEST_PROPS) || defined(VBOX_WITH_SHARED_CLIPBOARD) \
     74    || defined(VBOX_WITH_SHARED_CLIPBOARD_URI_LIST_DISABLED) || defined(VBOX_WITH_DRAG_AND_DROP)
     75# include "HGCM.h" /** @todo It should be possible to register a service
     76                    *        extension using a VMMDev callback. */
    7177#endif
    7278
     
    10471053    Bstr mstrUuid;
    10481054
     1055#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST_DISABLED
     1056    HGCMSVCEXTHANDLE m_hHgcmSvcExtShrdClipboard;
     1057#endif
     1058#ifdef VBOX_WITH_DRAG_AND_DROP
     1059    HGCMSVCEXTHANDLE m_hHgcmSvcExtDragAndDrop;
     1060#endif
     1061
    10491062    /** Pointer to the progress object of a live cancelable task.
    10501063     *
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r78901 r78915  
    82538253        /* Leave the lock since EMT might wait for it and will call us back as addVMCaller() */
    82548254        alock.release();
     8255
     8256#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST_DISABLED
     8257        if (m_hHgcmSvcExtShrdClipboard)
     8258        {
     8259            HGCMHostUnregisterServiceExtension(m_hHgcmSvcExtShrdClipboard);
     8260            m_hHgcmSvcExtShrdClipboard = NULL;
     8261        }
     8262#endif
     8263#ifdef VBOX_WITH_DRAG_AND_DROP
     8264        if (m_hHgcmSvcExtDragAndDrop)
     8265        {
     8266            HGCMHostUnregisterServiceExtension(m_hHgcmSvcExtDragAndDrop);
     8267            m_hHgcmSvcExtDragAndDrop = NULL;
     8268        }
     8269#endif
    82558270
    82568271        m_pVMMDev->hgcmShutdown();
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r78897 r78915  
    8686# include <VBox/com/defs.h>
    8787# include <VBox/com/array.h>
    88 # include "HGCM.h" /** @todo It should be possible to register a service
    89                     *        extension using a VMMDev callback. */
    9088# include <vector>
    9189#endif /* VBOX_WITH_GUEST_PROPS */
     
    30963094                {
    30973095                    LogRel(("Shared Clipboard: Service loaded\n"));
    3098                     HGCMSVCEXTHANDLE hDummy;
    3099                     rc = HGCMHostRegisterServiceExtension(&hDummy, "VBoxSharedClipboard",
     3096                    rc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtShrdClipboard, "VBoxSharedClipboard",
    31003097                                                          &Console::i_sharedClipboardServiceCallback,
    31013098                                                          this /* pvExtension */);
     
    31723169            else
    31733170            {
    3174                 HGCMSVCEXTHANDLE hDummy;
    3175                 rc = HGCMHostRegisterServiceExtension(&hDummy, "VBoxDragAndDropSvc",
     3171                rc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtDragAndDrop, "VBoxDragAndDropSvc",
    31763172                                                      &GuestDnD::notifyDnDDispatcher,
    31773173                                                      GUESTDNDINST());
  • trunk/src/VBox/Main/src-client/VMMDevInterface.cpp

    r76553 r78915  
    7272    /** Our HGCM connector interface. */
    7373    PDMIHGCMCONNECTOR           HGCMConnector;
     74#endif
     75
     76#ifdef VBOX_WITH_GUEST_PROPS
     77    HGCMSVCEXTHANDLE            hHgcmSvcExtGstProps;
     78#endif
     79#ifdef VBOX_WITH_GUEST_CONTROL
     80    HGCMSVCEXTHANDLE            hHgcmSvcExtGstCtrl;
    7481#endif
    7582} DRVMAINVMMDEV, *PDRVMAINVMMDEV;
     
    728735void VMMDev::hgcmShutdown(bool fUvmIsInvalid /*= false*/)
    729736{
     737#ifdef VBOX_WITH_GUEST_PROPS
     738    if (mpDrv->hHgcmSvcExtGstProps)
     739    {
     740        HGCMHostUnregisterServiceExtension(mpDrv->hHgcmSvcExtGstProps);
     741        mpDrv->hHgcmSvcExtGstProps = NULL;
     742    }
     743#endif
     744
     745#ifdef VBOX_WITH_GUEST_CONTROL
     746    if (mpDrv->hHgcmSvcExtGstCtrl)
     747    {
     748        HGCMHostUnregisterServiceExtension(mpDrv->hHgcmSvcExtGstCtrl);
     749        mpDrv->hHgcmSvcExtGstCtrl = NULL;
     750    }
     751#endif
     752
    730753    if (ASMAtomicCmpXchgBool(&m_fHGCMActive, false, true))
    731754        HGCMHostShutdown(fUvmIsInvalid);
     
    839862    PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
    840863    LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
     864
     865#ifdef VBOX_WITH_GUEST_PROPS
     866    if (pThis->hHgcmSvcExtGstProps)
     867    {
     868        HGCMHostUnregisterServiceExtension(pThis->hHgcmSvcExtGstProps);
     869        pThis->hHgcmSvcExtGstProps = NULL;
     870    }
     871#endif
     872
     873#ifdef VBOX_WITH_GUEST_CONTROL
     874    if (pThis->hHgcmSvcExtGstCtrl)
     875    {
     876        HGCMHostUnregisterServiceExtension(pThis->hHgcmSvcExtGstCtrl);
     877        pThis->hHgcmSvcExtGstCtrl = NULL;
     878    }
     879#endif
    841880
    842881    if (pThis->pVMMDev)
     
    10081047     * Register the host notification callback
    10091048     */
    1010     HGCMSVCEXTHANDLE hDummy;
    1011     HGCMHostRegisterServiceExtension(&hDummy, "VBoxGuestPropSvc", Console::i_doGuestPropNotification, ptrConsole.m_p);
     1049    HGCMHostRegisterServiceExtension(&mpDrv->hHgcmSvcExtGstProps, "VBoxGuestPropSvc", Console::i_doGuestPropNotification, ptrConsole.m_p);
    10121050
    10131051# ifdef VBOX_WITH_GUEST_PROPS_RDONLY_GUEST
     
    11361174    if (RT_SUCCESS(rc))
    11371175    {
    1138         HGCMSVCEXTHANDLE hDummy;
    1139         rc = HGCMHostRegisterServiceExtension(&hDummy, "VBoxGuestControlSvc",
     1176        rc = HGCMHostRegisterServiceExtension(&pThis->hHgcmSvcExtGstCtrl, "VBoxGuestControlSvc",
    11401177                                              &Guest::i_notifyCtrlDispatcher,
    11411178                                              pThis->pVMMDev->mParent->i_getGuest());
Note: See TracChangeset for help on using the changeset viewer.

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