VirtualBox

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


Ignore:
Timestamp:
Feb 28, 2014 3:41:58 PM (11 years ago)
Author:
vboxsync
Message:

Main/MachineImpl: well, if we use a counter there is no point in referencing the service more than once. Just make sure it is referenced at least once when the VM is powered on and all references are removed once the session machine is destroyed

File:
1 edited

Legend:

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

    r50651 r50652  
    1306613066    }
    1306713067
     13068    /* Remove all references to the NAT network service. The service will stop
     13069     * if all references (also from other VMs) are removed. */
    1306813070    for (; miNATNetworksStarted > 0; miNATNetworksStarted--)
    1306913071    {
     
    1325913261        mData->mSession.mProgress->setOtherProgressObject(aProgress);
    1326013262
    13261     for (ULONG slot = 0; slot < mNetworkAdapters.size(); slot++)
    13262     {
    13263         NetworkAttachmentType_T type;
    13264         HRESULT hrc;
    13265         hrc = mNetworkAdapters[slot]->COMGETTER(AttachmentType)(&type);
    13266         if (   SUCCEEDED(hrc)
    13267             && type == NetworkAttachmentType_NATNetwork)
    13268         {
    13269             Bstr name;
    13270             hrc = mNetworkAdapters[slot]->COMGETTER(NATNetwork)(name.asOutParam());
    13271             if (SUCCEEDED(hrc))
     13263    /* If we didn't reference the NAT network service yet, add a reference to
     13264     * force a start */
     13265    if (miNATNetworksStarted < 1)
     13266    {
     13267        for (ULONG slot = 0; slot < mNetworkAdapters.size(); slot++)
     13268        {
     13269            NetworkAttachmentType_T type;
     13270            HRESULT hrc;
     13271            hrc = mNetworkAdapters[slot]->COMGETTER(AttachmentType)(&type);
     13272            if (   SUCCEEDED(hrc)
     13273                && type == NetworkAttachmentType_NATNetwork)
    1327213274            {
    13273                 LogRel(("VM '%s' starts using NAT network '%ls'\n",
    13274                         mUserData->s.strName.c_str(), name.raw()));
    13275                 mPeer->lockHandle()->unlockWrite();
    13276                 mParent->i_natNetworkRefInc(name.raw());
     13275                Bstr name;
     13276                hrc = mNetworkAdapters[slot]->COMGETTER(NATNetwork)(name.asOutParam());
     13277                if (SUCCEEDED(hrc))
     13278                {
     13279                    LogRel(("VM '%s' starts using NAT network '%ls'\n",
     13280                            mUserData->s.strName.c_str(), name.raw()));
     13281                    mPeer->lockHandle()->unlockWrite();
     13282                    mParent->i_natNetworkRefInc(name.raw());
    1327713283#ifdef RT_LOCK_STRICT
    13278                 mPeer->lockHandle()->lockWrite(RT_SRC_POS);
     13284                    mPeer->lockHandle()->lockWrite(RT_SRC_POS);
    1327913285#else
    13280                 mPeer->lockHandle()->lockWrite();
     13286                    mPeer->lockHandle()->lockWrite();
    1328113287#endif
     13288                }
    1328213289            }
    1328313290        }
    13284     }
    13285 
    13286     miNATNetworksStarted++;
     13291        miNATNetworksStarted++;
     13292    }
    1328713293
    1328813294    LogFlowThisFunc(("returns S_OK.\n"));
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