VirtualBox

Changeset 91097 in vbox


Ignore:
Timestamp:
Sep 2, 2021 2:42:26 PM (3 years ago)
Author:
vboxsync
Message:

HGCM: Put back pfnDisconnectClient. oem2ticketref:46

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/hgcmsvc.h

    r90833 r91097  
    8383 * 8.1->9.1 Because pfnDisconnectClient was (temporarily) removed, and
    8484 *          acMaxClients and acMaxCallsPerClient added (VBox 6.1.26).
     85 * 9.1->10.1 Because pfnDisconnectClient was added back (VBox 6.1.28).
    8586 */
    8687#define VBOX_HGCM_SVC_VERSION_MAJOR (0x0009)
     
    101102    void *pvInstance;
    102103
    103 #if 0 /* Not thread safe. */
    104     /** The service disconnects the client. */
    105     DECLR3CALLBACKMEMBER(void, pfnDisconnectClient, (void *pvInstance, uint32_t u32ClientID));
    106 #endif
     104    /**
     105     * The service disconnects the client.
     106     *
     107     * This can only be used during VBOXHGCMSVCFNTABLE::pfnConnect or
     108     * VBOXHGCMSVCFNTABLE::pfnDisconnect and will fail if called out side that
     109     * context.
     110     *
     111     * There will be no VBOXHGCMSVCFNTABLE::pfnDisconnect callback for a client
     112     * diconnected in this manner.
     113     *
     114     * @returns VBox status code.
     115     * @retval  VERR_NOT_FOUND if the client ID was not found.
     116     * @retval  VERR_INVALID_CONTEXT if not called during connect or disconnect.
     117     *
     118     * @remarks Used by external parties, so don't remove just because we don't use
     119     *          it ourselves.
     120     */
     121    DECLR3CALLBACKMEMBER(int, pfnDisconnectClient, (void *pvInstance, uint32_t u32ClientID));
    107122
    108123    /**
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r90267 r91097  
    109109        VBOXHGCMSVCFNTABLE m_fntable;
    110110
     111        /** Set if servicing SVC_MSG_CONNECT or SVC_MSG_DISCONNECT.
     112         * Used for context checking pfnDisconnectClient calls, as it can only
     113         * safely be made when the main HGCM thread is waiting on the service to
     114         * process those messages. */
     115        bool m_fInConnectOrDisconnect;
     116
    111117        uint32_t m_acClients[HGCM_CLIENT_CATEGORY_MAX]; /**< Clients per category. */
    112118        uint32_t m_cClients;
     
    143149
    144150        static DECLCALLBACK(int)  svcHlpCallComplete(VBOXHGCMCALLHANDLE callHandle, int32_t rc);
    145         static DECLCALLBACK(void) svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId);
     151        static DECLCALLBACK(int) svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId);
    146152        static DECLCALLBACK(bool) svcHlpIsCallRestored(VBOXHGCMCALLHANDLE callHandle);
    147153        static DECLCALLBACK(bool) svcHlpIsCallCancelled(VBOXHGCMCALLHANDLE callHandle);
     
    282288    m_hLdrMod    (NIL_RTLDRMOD),
    283289    m_pfnLoad    (NULL),
     290    m_fInConnectOrDisconnect(false),
    284291    m_cClients   (0),
    285292    m_cClientsAllocated (0),
     
    672679                if (pClient)
    673680                {
     681                    pSvc->m_fInConnectOrDisconnect = true;
    674682                    rc = pSvc->m_fntable.pfnConnect(pSvc->m_fntable.pvService, pMsg->u32ClientId,
    675683                                                    HGCM_CLIENT_DATA(pSvc, pClient),
    676684                                                    pMsg->fRequestor, pMsg->fRestoring);
     685                    pSvc->m_fInConnectOrDisconnect = false;
    677686
    678687                    hgcmObjDereference(pClient);
     
    692701                if (pMsg->pClient)
    693702                {
     703                    pSvc->m_fInConnectOrDisconnect = true;
    694704                    rc = pSvc->m_fntable.pfnDisconnect(pSvc->m_fntable.pvService, pMsg->u32ClientId,
    695705                                                       HGCM_CLIENT_DATA(pSvc, pMsg->pClient));
     706                    pSvc->m_fInConnectOrDisconnect = false;
    696707                }
    697708                else
     
    913924}
    914925
    915 #if 0 /* not thread safe */
    916926/**
    917927 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnDisconnectClient}
    918928 */
    919 /* static */ DECLCALLBACK(void) HGCMService::svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId)
     929/* static */ DECLCALLBACK(int) HGCMService::svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId)
    920930{
    921931     HGCMService *pService = static_cast <HGCMService *> (pvInstance);
    922 
    923      AssertMsgFailed(("This is unused code with a serialization issue.\n"
    924                       "It touches data which is normally serialized by only running on the HGCM thread!\n"));
    925 
    926      if (pService)
    927      {
    928          pService->DisconnectClient(u32ClientId, true, NULL);
    929      }
    930 }
    931 #endif
     932     AssertReturn(pService, VERR_INVALID_HANDLE);
     933
     934     /* Only safe to call when the main HGCM thread is waiting on the service
     935        to handle a SVC_MSG_CONNECT or SVC_MSG_DISCONNECT message.  Otherwise
     936        we'd risk racing it and corrupt data structures. */
     937     AssertReturn(pService->m_fInConnectOrDisconnect, VERR_INVALID_CONTEXT);
     938
     939     return pService->DisconnectClient(u32ClientId, true, NULL);
     940}
    932941
    933942/**
     
    11351144            m_svcHelpers.pfnCallComplete       = svcHlpCallComplete;
    11361145            m_svcHelpers.pvInstance            = this;
    1137 #if 0 /* not thread safe */
    11381146            m_svcHelpers.pfnDisconnectClient   = svcHlpDisconnectClient;
    1139 #endif
    11401147            m_svcHelpers.pfnIsCallRestored     = svcHlpIsCallRestored;
    11411148            m_svcHelpers.pfnIsCallCancelled    = svcHlpIsCallCancelled;
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