VirtualBox

Changeset 91100 in vbox


Ignore:
Timestamp:
Sep 2, 2021 9:01:51 PM (3 years ago)
Author:
vboxsync
Message:

HGCM: Fixes to svcHlpDisconnectClient / DisconnectClient. Documentation updates. oem2ticketref:46 bugref:10038

Location:
trunk
Files:
2 edited

Legend:

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

    r91097 r91100  
    107107     * This can only be used during VBOXHGCMSVCFNTABLE::pfnConnect or
    108108     * VBOXHGCMSVCFNTABLE::pfnDisconnect and will fail if called out side that
    109      * context.
     109     * context.  Using this on the new client during VBOXHGCMSVCFNTABLE::pfnConnect
     110     * is not advisable, it would be better to just return a failure status for that
     111     * and it will be done automatically.  (It is not possible to call this method
     112     * on a client passed to VBOXHGCMSVCFNTABLE::pfnDisconnect.)
    110113     *
    111114     * There will be no VBOXHGCMSVCFNTABLE::pfnDisconnect callback for a client
     
    119122     *          it ourselves.
    120123     */
    121     DECLR3CALLBACKMEMBER(int, pfnDisconnectClient, (void *pvInstance, uint32_t u32ClientID));
     124    DECLR3CALLBACKMEMBER(int, pfnDisconnectClient, (void *pvInstance, uint32_t idClient));
    122125
    123126    /**
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r91097 r91100  
    149149
    150150        static DECLCALLBACK(int)  svcHlpCallComplete(VBOXHGCMCALLHANDLE callHandle, int32_t rc);
    151         static DECLCALLBACK(int)  svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId);
     151        static DECLCALLBACK(int)  svcHlpDisconnectClient(void *pvInstance, uint32_t idClient);
    152152        static DECLCALLBACK(bool) svcHlpIsCallRestored(VBOXHGCMCALLHANDLE callHandle);
    153153        static DECLCALLBACK(bool) svcHlpIsCallCancelled(VBOXHGCMCALLHANDLE callHandle);
     
    927927 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnDisconnectClient}
    928928 */
    929 /* static */ DECLCALLBACK(int) HGCMService::svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId)
     929/* static */ DECLCALLBACK(int) HGCMService::svcHlpDisconnectClient(void *pvInstance, uint32_t idClient)
    930930{
    931931     HGCMService *pService = static_cast <HGCMService *> (pvInstance);
     
    937937     AssertReturn(pService->m_fInConnectOrDisconnect, VERR_INVALID_CONTEXT);
    938938
    939      return pService->DisconnectClient(u32ClientId, true, NULL);
     939     /* Resolve the client ID and verify that it belongs to this service before
     940        trying to disconnect it. */
     941     int rc = VERR_NOT_FOUND;
     942     HGCMClient * const pClient = (HGCMClient *)hgcmObjReference(idClient, HGCMOBJ_CLIENT);
     943     if (pClient)
     944     {
     945         if (pClient->pService == pService)
     946             rc = pService->DisconnectClient(idClient, true, pClient);
     947         hgcmObjDereference(pClient);
     948     }
     949     return rc;
    940950}
    941951
     
    17941804 * @param   u32ClientId     The handle of the client.
    17951805 * @param   fFromService    Set if called by the service via
    1796  *                          svcHlpDisconnectClient().  pClient can be NULL when
    1797  *                          this is @c true.
    1798  * @param   pClient         The client disconnecting.  NULL if from service.
     1806 *                          svcHlpDisconnectClient().
     1807 * @param   pClient         The client disconnecting.
    17991808 * @return  VBox status code.
    18001809 */
    18011810int HGCMService::DisconnectClient(uint32_t u32ClientId, bool fFromService, HGCMClient *pClient)
    18021811{
    1803     Assert(pClient || !fFromService);
    1804 
     1812    AssertPtr(pClient);
    18051813    LogFlowFunc(("client id = %d, fFromService = %d, pClient = %p\n", u32ClientId, fFromService, pClient));
    18061814
     
    18471855    }
    18481856
    1849     if (pClient)
    1850         LogFunc(("idClient=%u m_cClients=%u m_acClients[%u]=%u %s (cPendingCalls=%u) rc=%Rrc\n", u32ClientId, m_cClients,
    1851                  pClient->idxCategory, m_acClients[pClient->idxCategory], m_pszSvcName, pClient->cPendingCalls, rc));
     1857    LogFunc(("idClient=%u m_cClients=%u m_acClients[%u]=%u %s (cPendingCalls=%u) rc=%Rrc\n", u32ClientId, m_cClients,
     1858             pClient->idxCategory, m_acClients[pClient->idxCategory], m_pszSvcName, pClient->cPendingCalls, rc));
    18521859
    18531860    /*
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