VirtualBox

Changeset 50810 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 18, 2014 2:53:28 PM (11 years ago)
Author:
vboxsync
Message:

VBoxService/GuestCtrl: Do a HGCM reconnect on saved state restore when the guest session changed; don't try too hard though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r49349 r50810  
    55
    66/*
    7  * Copyright (C) 2012-2013 Oracle Corporation
     7 * Copyright (C) 2012-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    208208    ctxHost.uProtocol = 1;
    209209
     210    int cRetrievalFailed = 0; /* Number of failed message retrievals in a row. */
    210211    for (;;)
    211212    {
     
    217218        {
    218219#ifdef DEBUG
    219             VBoxServiceVerbose(4, "Message requires %ld parameters, but only 2 supplied -- retrying request (no error!)...\n", cParms);
     220            VBoxServiceVerbose(4, "Message requires %ld parameters, but only 2 supplied -- retrying request (no error!)...\n",
     221                               cParms);
    220222#endif
    221223            rc = VINF_SUCCESS; /* Try to get "real" message in next block below. */
    222224        }
    223225        else if (RT_FAILURE(rc))
    224             VBoxServiceVerbose(3, "Getting host message failed with %Rrc\n", rc); /* VERR_GEN_IO_FAILURE seems to be normal if ran into timeout. */
     226        {
     227            /* Note: VERR_GEN_IO_FAILURE seems to be normal if ran into timeout. */
     228            VBoxServiceError("Getting host message failed with %Rrc\n", rc);
     229
     230            /* Check for VM session change. */
     231            uint64_t idNewSession = g_idControlSession;
     232            int rc2 = VbglR3GetSessionId(&idNewSession);
     233            if (   RT_SUCCESS(rc2)
     234                && (idNewSession != g_idControlSession))
     235            {
     236                VBoxServiceVerbose(1, "The VM session ID changed\n");
     237                g_idControlSession = idNewSession;
     238
     239                /* Close all opened guest sessions -- all context IDs, sessions etc.
     240                 * are now invalid. */
     241                rc2 = GstCntlSessionClose(&g_Session);
     242                AssertRC(rc2);
     243
     244                /* Do a reconnect. */
     245                VBoxServiceVerbose(1, "Reconnecting to HGCM service ...\n");
     246                rc2 = VbglR3GuestCtrlConnect(&g_uControlSvcClientID);
     247                if (RT_SUCCESS(rc2))
     248                {
     249                    VBoxServiceVerbose(3, "Guest control service client ID=%RU32\n",
     250                                       g_uControlSvcClientID);
     251                    cRetrievalFailed = 0;
     252                    continue; /* Skip waiting. */
     253                }
     254                else
     255                {
     256                    VBoxServiceError("Unable to re-connect to HGCM service, rc=%Rrc, bailing out\n", rc);
     257                    break;
     258                }
     259            }
     260
     261            if (++cRetrievalFailed > 16) /** @todo Make this configurable? */
     262            {
     263                VBoxServiceError("Too many failed attempts in a row to get next message, bailing out\n");
     264                break;
     265            }
     266
     267            RTThreadSleep(1000); /* Wait a bit before retrying. */
     268        }
     269
    225270        if (RT_SUCCESS(rc))
    226271        {
    227272            VBoxServiceVerbose(4, "Msg=%RU32 (%RU32 parms) retrieved\n", uMsg, cParms);
     273            cRetrievalFailed = 0; /* Reset failed retrieval count. */
    228274
    229275            /* Set number of parameters for current host context. */
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