VirtualBox

Changeset 15604 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Dec 16, 2008 7:20:17 PM (16 years ago)
Author:
vboxsync
Message:

Main: #3400: Fixed a race between the VBoxSVC shutdown timer and clients wanting new objects.

Location:
trunk/src/VBox/Main/xpcom
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xpcom/server.cpp

    r15570 r15604  
    338338
    339339        FinalRelease();
    340         sInstance = 0;
     340        sInstance = NULL;
    341341
    342342        LogFlowFunc (("VirtualBox object deleted.\n"));
     
    362362            PRBool timerStarted = PR_FALSE;
    363363
    364             /* sTimes is null if this call originates from
    365              * FactoryDestructor() */
     364            /* sTimer is null if this call originates from FactoryDestructor()*/
    366365            if (sTimer != NULL)
    367366            {
     
    456455            else
    457456            {
    458                 /* This condition is quite rare: a new client will have to
     457                /* This condition is quite rare: a new client happened to
    459458                 * connect after this event has been posted to the main queue
    460459                 * but before it started to process it. */
     
    516515        RTCritSectDelete (&sLock);
    517516
    518         if (sInstance)
     517        if (sInstance != NULL)
    519518        {
    520519            /* Either posting a destruction event falied for some reason (most
     
    535534        RTCritSectEnter (&sLock);
    536535
    537         int rv = NS_OK;
    538 
    539         if (sInstance == 0)
     536        if (!gKeepRunning)
     537        {
     538            LogFlowFunc (("Process termination requested first. Refusing.\n"));
     539
     540            RTCritSectLeave (&sLock);
     541
     542            /* this rv is what CreateInstance() on the client side returns
     543             * when the server process stops accepting events. Do the same
     544             * here. The client wrapper should attempt to start a new process in
     545             * response to a failure from us. */
     546            return NS_ERROR_ABORT;
     547        }
     548
     549        nsresult rv = NS_OK;
     550
     551        if (sInstance == NULL)
    540552        {
    541553            LogFlowFunc (("Creating new VirtualBox object...\n"));
    542554            sInstance = new VirtualBoxClassFactory();
    543             if (sInstance)
     555            if (sInstance != NULL)
    544556            {
    545557                /* make an extra AddRef to take the full control
     
    563575                    sInstance->Release();
    564576                    sInstance->Release();
    565                     Assert (sInstance == 0);
     577                    Assert (sInstance == NULL);
    566578                }
    567579                else
     
    614626};
    615627
    616 VirtualBoxClassFactory *VirtualBoxClassFactory::sInstance = 0;
     628VirtualBoxClassFactory *VirtualBoxClassFactory::sInstance = NULL;
    617629RTCRITSECT VirtualBoxClassFactory::sLock = {0};
    618630
     
    11521164        }
    11531165
     1166        /* stop accepting new events. Clients that happen to resolve our
     1167         * name and issue a CreateInstance() request after this point will
     1168         * get NS_ERROR_ABORT once we hande the remaining messages. As a
     1169         * result, they should try to start a new server process. */
     1170        gEventQ->StopAcceptingEvents();
     1171
     1172        /* unregister ourselves. After this point, clients will start a new
     1173         * process because they won't be able to resolve the server name.*/
    11541174        gIpcServ->RemoveName (VBOXSVC_IPC_NAME);
    11551175
    1156         /* stop accepting new events */
    1157         gEventQ->StopAcceptingEvents();
    1158 
    1159         /* process any remaining events */
     1176        /* process any remaining events. These events may include
     1177         * CreateInstance() requests received right before we called
     1178         * StopAcceptingEvents() above. We will detect this case below,
     1179         * restore gKeepRunning and continue to serve. */
    11601180        gEventQ->ProcessPendingEvents();
    11611181
  • trunk/src/VBox/Main/xpcom/server_module.cpp

    r14323 r15604  
    229229                break;
    230230
     231            LogFlowFunc (("Failed to connect (rc=%Rhrc (%#08x))\n", rc, rc));
     232
    231233            /* It's possible that the server gets shut down after we
    232234             * successfully resolve the server name but before it
     
    239241                if (NS_SUCCEEDED (rc2))
    240242                    break;
     243
     244                LogFlowFunc (("Server seems to have terminated before "
     245                              "receiving our request. Will try again.\n"));
    241246            }
    242247            else
     
    247252    while (0);
    248253
    249     LogFlowFunc (("rc=%08X, vrc=%Rrc\n", rc, vrc));
     254    LogFlowFunc (("rc=%Rhrc (%#08x), vrc=%Rrc\n", rc, rc, vrc));
    250255    LogFlowFuncLeave();
    251256
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