VirtualBox

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


Ignore:
Timestamp:
Jun 18, 2013 8:23:31 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86490
Message:

Main: properly fixed the return code of VRDEServer::COMSETTER(Enabled) and fixed locking + some comments in ConsoleImpl

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r46584 r46610  
    44384438    HRESULT rc = S_OK;
    44394439
    4440     /* don't trigger network change if the VM isn't running */
     4440    /* don't trigger network changes if the VM isn't running */
    44414441    SafeVMPtrQuiet ptrVM(this);
    44424442    if (ptrVM.isOk())
     
    45514551    HRESULT rc = S_OK;
    45524552
    4553     /* don't trigger nat engine change if the VM isn't running */
     4553    /* don't trigger NAT engine changes if the VM isn't running */
    45544554    SafeVMPtrQuiet ptrVM(this);
    45554555    if (ptrVM.isOk())
     
    48604860    HRESULT rc = S_OK;
    48614861
    4862     /* don't trigger medium change if the VM isn't running */
     4862    /* don't trigger medium changes if the VM isn't running */
    48634863    SafeVMPtrQuiet ptrVM(this);
    48644864    if (ptrVM.isOk())
     
    48904890    HRESULT rc = S_OK;
    48914891
    4892     /* don't trigger CPU change if the VM isn't running */
     4892    /* don't trigger CPU changes if the VM isn't running */
    48934893    SafeVMPtrQuiet ptrVM(this);
    48944894    if (ptrVM.isOk())
     
    49694969    HRESULT rc = S_OK;
    49704970
    4971     /* don't trigger the Clipboard mode change if the VM isn't running */
     4971    /* don't trigger the clipboard mode change if the VM isn't running */
    49724972    SafeVMPtrQuiet ptrVM(this);
    49734973    if (ptrVM.isOk())
     
    50095009    HRESULT rc = S_OK;
    50105010
    5011     /* don't trigger the Drag'n'drop mode change if the VM isn't running */
     5011    /* don't trigger the drag'n'drop mode change if the VM isn't running */
    50125012    SafeVMPtrQuiet ptrVM(this);
    50135013    if (ptrVM.isOk())
     
    50475047    HRESULT rc = S_OK;
    50485048
    5049     if (    mVRDEServer
    5050         &&  (   mMachineState == MachineState_Running
    5051              || mMachineState == MachineState_Teleporting
    5052              || mMachineState == MachineState_LiveSnapshotting
    5053              || mMachineState == MachineState_Paused
    5054             )
    5055        )
    5056     {
    5057         BOOL vrdpEnabled = FALSE;
    5058 
    5059         rc = mVRDEServer->COMGETTER(Enabled)(&vrdpEnabled);
    5060         ComAssertComRCRetRC(rc);
    5061 
    5062         if (aRestart)
    5063         {
    5064             /* VRDP server may call this Console object back from other threads (VRDP INPUT or OUTPUT). */
    5065             alock.release();
    5066 
    5067             if (vrdpEnabled)
     5049    /* don't trigger VRDE server changes if the VM isn't running */
     5050    SafeVMPtrQuiet ptrVM(this);
     5051    if (ptrVM.isOk())
     5052    {
     5053        if (    mVRDEServer
     5054            &&  (   mMachineState == MachineState_Running
     5055                 || mMachineState == MachineState_Teleporting
     5056                 || mMachineState == MachineState_LiveSnapshotting
     5057                 || mMachineState == MachineState_Paused
     5058                 )
     5059           )
     5060        {
     5061            BOOL vrdpEnabled = FALSE;
     5062
     5063            rc = mVRDEServer->COMGETTER(Enabled)(&vrdpEnabled);
     5064            ComAssertComRCRetRC(rc);
     5065
     5066            if (aRestart)
    50685067            {
    5069                 // If there was no VRDP server started the 'stop' will do nothing.
    5070                 // However if a server was started and this notification was called,
    5071                 // we have to restart the server.
    5072                 mConsoleVRDPServer->Stop();
    5073 
    5074                 if (RT_FAILURE(mConsoleVRDPServer->Launch()))
    5075                     rc = E_FAIL;
     5068                /* VRDP server may call this Console object back from other threads (VRDP INPUT or OUTPUT). */
     5069                alock.release();
     5070
     5071                if (vrdpEnabled)
     5072                {
     5073                    // If there was no VRDP server started the 'stop' will do nothing.
     5074                    // However if a server was started and this notification was called,
     5075                    // we have to restart the server.
     5076                    mConsoleVRDPServer->Stop();
     5077
     5078                    if (RT_FAILURE(mConsoleVRDPServer->Launch()))
     5079                        rc = E_FAIL;
     5080                    else
     5081                        mConsoleVRDPServer->EnableConnections();
     5082                }
    50765083                else
    5077                     mConsoleVRDPServer->EnableConnections();
     5084                    mConsoleVRDPServer->Stop();
     5085
     5086                alock.acquire();
     5087            }
     5088        }
     5089        else
     5090            rc = setInvalidMachineStateError();
     5091        ptrVM.release();
     5092    }
     5093
     5094    /* notify console callbacks on success */
     5095    if (SUCCEEDED(rc))
     5096    {
     5097        alock.release();
     5098        fireVRDEServerChangedEvent(mEventSource);
     5099    }
     5100
     5101    return rc;
     5102}
     5103
     5104void Console::onVRDEServerInfoChange()
     5105{
     5106    AutoCaller autoCaller(this);
     5107    AssertComRCReturnVoid(autoCaller.rc());
     5108
     5109    fireVRDEServerInfoChangedEvent(mEventSource);
     5110}
     5111
     5112HRESULT Console::onVideoCaptureChange()
     5113{
     5114    AutoCaller autoCaller(this);
     5115    AssertComRCReturnRC(autoCaller.rc());
     5116
     5117    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     5118
     5119    HRESULT rc = S_OK;
     5120
     5121    /* don't trigger video capture changes if the VM isn't running */
     5122    SafeVMPtrQuiet ptrVM(this);
     5123    if (ptrVM.isOk())
     5124    {
     5125        BOOL fEnabled;
     5126        rc = mMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
     5127        SafeArray<BOOL> screens;
     5128        if (SUCCEEDED(rc))
     5129            rc = mMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens));
     5130        if (mDisplay)
     5131        {
     5132            int vrc = VINF_SUCCESS;
     5133            if (SUCCEEDED(rc))
     5134                vrc = mDisplay->VideoCaptureEnableScreens(ComSafeArrayAsInParam(screens));
     5135            if (RT_SUCCESS(vrc))
     5136            {
     5137                if (fEnabled)
     5138                {
     5139                    vrc = mDisplay->VideoCaptureStart();
     5140                    if (RT_FAILURE(vrc))
     5141                        rc = E_FAIL;
     5142                }
     5143                else
     5144                    mDisplay->VideoCaptureStop();
    50785145            }
    50795146            else
    5080             {
    5081                 mConsoleVRDPServer->Stop();
    5082             }
    5083 
    5084             alock.acquire();
    5085         }
    5086     }
    5087     else
    5088         rc = setInvalidMachineStateError();
     5147                rc = E_FAIL;
     5148        }
     5149        ptrVM.release();
     5150    }
    50895151
    50905152    /* notify console callbacks on success */
     
    50925154    {
    50935155        alock.release();
    5094         fireVRDEServerChangedEvent(mEventSource);
    5095     }
    5096 
    5097     return rc;
    5098 }
    5099 
    5100 void Console::onVRDEServerInfoChange()
    5101 {
    5102     AutoCaller autoCaller(this);
    5103     AssertComRCReturnVoid(autoCaller.rc());
    5104 
    5105     fireVRDEServerInfoChangedEvent(mEventSource);
    5106 }
    5107 
    5108 HRESULT Console::onVideoCaptureChange()
    5109 {
    5110     AutoCaller autoCaller(this);
    5111     AssertComRCReturnRC(autoCaller.rc());
    5112 
    5113     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    5114 
    5115     BOOL fEnabled;
    5116     HRESULT rc = mMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
    5117     SafeArray<BOOL> screens;
    5118     if (SUCCEEDED(rc))
    5119         rc = mMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens));
    5120     if (mDisplay)
    5121     {
    5122         int vrc = VINF_SUCCESS;
    5123         if (SUCCEEDED(rc))
    5124             vrc = mDisplay->VideoCaptureEnableScreens(ComSafeArrayAsInParam(screens));
    5125         if (RT_SUCCESS(vrc))
    5126         {
    5127             if (fEnabled)
    5128                 vrc = mDisplay->VideoCaptureStart();
    5129             else
    5130                 mDisplay->VideoCaptureStop();
    5131             if (RT_SUCCESS(vrc))
    5132                 fireVideoCaptureChangedEvent(mEventSource);
    5133             else
    5134                 rc = E_FAIL;
    5135         }
     5156        fireVideoCaptureChangedEvent(mEventSource);
    51365157    }
    51375158
     
    53635384    HRESULT rc = S_OK;
    53645385
    5365     /* don't trigger the CPU priority change if the VM isn't running */
     5386    /* don't trigger bandwidth group changes if the VM isn't running */
    53665387    SafeVMPtrQuiet ptrVM(this);
    53675388    if (ptrVM.isOk())
     
    54265447    HRESULT rc = S_OK;
    54275448
    5428     /* don't trigger medium change if the VM isn't running */
     5449    /* don't trigger medium changes if the VM isn't running */
    54295450    SafeVMPtrQuiet ptrVM(this);
    54305451    if (ptrVM.isOk())
  • trunk/src/VBox/Main/src-server/VRDEServerImpl.cpp

    r46609 r46610  
    289289    }
    290290
    291 #if 0
    292291    return rc;
    293 #else
    294     return S_OK;
    295 #endif
    296292}
    297293
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