VirtualBox

Changeset 6981 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Feb 18, 2008 10:05:36 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28172
Message:

HostServices/SharedClipboard: attempt to handle the guest reconnecting without first disconnecting more gracefully

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/service.cpp

    r5999 r6981  
    234234}
    235235
     236/**
     237 * Disconnect the host side of the shared clipboard and send a "host disconnected" message
     238 * to the guest side.
     239 */
     240static DECLCALLBACK(int) svcDisconnect (uint32_t u32ClientID, void *pvClient)
     241{
     242    VBOXCLIPBOARDCLIENTDATA *pClient = (VBOXCLIPBOARDCLIENTDATA *)pvClient;
     243
     244    vboxSvcClipboardReportMsg (pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT, 0);
     245
     246    vboxClipboardDisconnect (pClient);
     247
     248    memset (pClient, 0, sizeof (*pClient));
     249
     250    g_pClient = NULL;
     251
     252    return VINF_SUCCESS;
     253}
     254
    236255static DECLCALLBACK(int) svcConnect (uint32_t u32ClientID, void *pvClient)
    237256{
    238257    VBOXCLIPBOARDCLIENTDATA *pClient = (VBOXCLIPBOARDCLIENTDATA *)pvClient;
    239258
     259    int rc = VINF_SUCCESS;
     260
     261    /* If there is already a client connected then we want to release it first. */
     262    if (g_pClient != NULL)
     263    {
     264        uint32_t u32ClientID = g_pClient->u32ClientID;
     265
     266        svcDisconnect(u32ClientID, g_pClient);
     267        /* And free the resources in the hgcm subsystem. */
     268        g_pHelpers->pfnDisconnectClient(g_pHelpers->pvInstance, u32ClientID);
     269    }
     270
    240271    /* Register the client. */
    241     int rc = VINF_SUCCESS;
    242 
    243272    memset (pClient, 0, sizeof (*pClient));
    244273
     
    246275
    247276    rc = vboxClipboardConnect (pClient);
    248    
     277
    249278    if (VBOX_SUCCESS (rc))
    250279    {
    251280        g_pClient = pClient;
    252281    }
    253    
     282
    254283    Log(("vboxClipboardConnect: rc = %Vrc\n", rc));
    255284
    256285    return rc;
    257 }
    258 
    259 static DECLCALLBACK(int) svcDisconnect (uint32_t u32ClientID, void *pvClient)
    260 {
    261     VBOXCLIPBOARDCLIENTDATA *pClient = (VBOXCLIPBOARDCLIENTDATA *)pvClient;
    262 
    263     vboxSvcClipboardReportMsg (pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT, 0);
    264 
    265     vboxClipboardDisconnect (pClient);
    266 
    267     memset (pClient, 0, sizeof (*pClient));
    268 
    269     g_pClient = NULL;
    270        
    271     return VINF_SUCCESS;
    272286}
    273287
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