VirtualBox

Changeset 40465 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Mar 14, 2012 2:28:33 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76831
Message:

Main/Console: fix various regression from the locking cleanup

File:
1 edited

Legend:

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

    r40302 r40465  
    24352435        return ptrVM.rc();
    24362436
    2437 /** @todo release the console lock? */
     2437    // no need to release lock, as there are no cross-thread callbacks
    24382438
    24392439    /* get the acpi device interface and press the button. */
     
    24832483        return ptrVM.rc();
    24842484
    2485 /** @todo release the console lock? */
     2485    // no need to release lock, as there are no cross-thread callbacks
    24862486
    24872487    /* get the acpi device interface and check if the button press was handled. */
     
    25382538        return ptrVM.rc();
    25392539
    2540 /** @todo release the console lock? */
     2540    // no need to release lock, as there are no cross-thread callbacks
    25412541
    25422542    /* get the acpi device interface and query the information. */
     
    25792579        return ptrVM.rc();
    25802580
    2581 /** @todo release the console lock? */
     2581    // no need to release lock, as there are no cross-thread callbacks
    25822582
    25832583    /* get the acpi device interface and press the sleep button. */
     
    28002800}
    28012801
    2802 /** read the value of a LEd. */
     2802/** read the value of a LED. */
    28032803inline uint32_t readAndClearLed(PPDMLED pLed)
    28042804{
     
    43234323                AssertComRC(rc);
    43244324                const char *pszAdapterName = networkAdapterTypeToName(adapterType);
     4325
     4326                // prevent cross-thread deadlocks, don't need the lock any more
     4327                alock.release();
     4328
    43254329                PPDMIBASE pBase;
    43264330                int vrc = PDMR3QueryDeviceLun(ptrVM, pszAdapterName, ulInstance, 0, &pBase);
     
    43744378    }
    43754379
     4380    // definitely don't need the lock any more
     4381    alock.release();
     4382
    43764383    /* notify console callbacks on success */
    43774384    if (SUCCEEDED(rc))
    4378     {
    4379         alock.release(); /** @todo 101% safe? */
    43804385        fireNetworkAdapterChangedEvent(mEventSource, aNetworkAdapter);
    4381     }
    43824386
    43834387    LogFlowThisFunc(("Leaving rc=%#x\n", rc));
     
    44854489 * @param   uLun                The PDM LUN number of the drive.
    44864490 * @param   aNetworkAdapter     The network adapter whose attachment needs to be changed
    4487  *
    4488  * @note Locks this object for writing.
    44894491 */
    44904492HRESULT Console::doNetworkAdapterChange(PVM pVM,
     
    44994501    AutoCaller autoCaller(this);
    45004502    AssertComRCReturnRC(autoCaller.rc());
    4501 
    4502     /* We will need to release the write lock before calling EMT */
    4503     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    45044503
    45054504    /* Get the VM handle. */
     
    45174516                          (PFNRT) Console::changeNetworkAttachment, 6,
    45184517                          this, ptrVM.raw(), pszDevice, uInstance, uLun, aNetworkAdapter);
    4519 
    4520     /* release the lock before waiting for a result (EMT will call us back!) */
    4521     alock.release();
    45224518
    45234519    if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
     
    49684964    if (aError != NULL)
    49694965    {
     4966        alock.release();
    49704967        /* notify callbacks about the error */
    49714968        onUSBDeviceStateChange(aDevice, true /* aAttached */, aError);
     
    49794976        return E_FAIL;
    49804977    }
     4978
     4979    alock.release();
    49814980
    49824981    HRESULT rc = attachUSBDevice(aDevice, aMaskedIfs);
     
    50555054        AssertFailedReturn(E_FAIL);
    50565055    }
     5056
     5057    alock.release();
    50575058
    50585059    if (aError != NULL)
     
    51545155    AssertComRCReturnRC(autoCaller.rc());
    51555156
    5156     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    5157 
    51585157    HRESULT rc = S_OK;
    51595158
     
    51715170    /* notify console callbacks on success */
    51725171    if (SUCCEEDED(rc))
    5173     {
    5174         alock.release(); /** @todo 101% safe? */
    51755172        fireStorageDeviceChangedEvent(mEventSource, aMediumAttachment, aRemove);
    5176     }
    51775173
    51785174    LogFlowThisFunc(("Leaving rc=%#x\n", rc));
     
    68136809            {
    68146810                fHasUSBController = true;
     6811                alock.release();
    68156812                detachAllUSBDevices(false /* aDone */);
     6813                alock.acquire();
    68166814            }
    68176815        }
     
    68666864        /* Complete the detaching of the USB devices. */
    68676865        if (fHasUSBController)
     6866        {
     6867            alock.release();
    68686868            detachAllUSBDevices(true /* aDone */);
     6869            alock.acquire();
     6870        }
    68696871
    68706872        /* advance percent count */
     
    76617663    AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
    76627664
    7663     /* still want a lock object because we need to release it */
    7664     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    7665 
    76667665    HRESULT hrc;
    76677666
     
    76937692                      Address.c_str(), uuid.raw()));
    76947693
    7695     /* release the lock before a VMR3* call (EMT will call us back)! */
    7696     alock.release();
    7697 
    76987694/** @todo just do everything here and only wrap the PDMR3Usb call. That'll offload some notification stuff from the EMT thread. */
    76997695    int vrc = VMR3ReqCallWait(ptrVM, VMCPUID_ANY,
    77007696                              (PFNRT)usbAttachCallback, 7,
    77017697                              this, ptrVM.raw(), aHostDevice, uuid.raw(), fRemote, Address.c_str(), aMaskedIfs);
    7702 
    7703     /* restore the lock */
    7704     alock.acquire();
    77057698
    77067699    /* hrc is S_OK here */
     
    77807773        LogFlowFunc(("Attached device {%RTuuid}\n", pUSBDevice->id().raw()));
    77817774
     7775        alock.release();
     7776
    77827777        /* notify callbacks */
    77837778        that->onUSBDeviceStateChange(pUSBDevice, true /* aAttached */, NULL);
     
    78037798    AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
    78047799
    7805     /* still want a lock object because we need to release it */
    7806     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    7807 
    78087800    /* Get the VM handle. */
    78097801    SafeVMPtr ptrVM(this);
     
    78167808    LogFlowThisFunc(("Detaching USB proxy device {%RTuuid}...\n",
    78177809                     (*aIt)->id().raw()));
    7818 
    7819     /* release the lock before a VMR3* call (EMT will call us back)! */
    7820     alock.release();
    78217810
    78227811/** @todo just do everything here and only wrap the PDMR3Usb call. That'll offload some notification stuff from the EMT thread. */
     
    78737862        that->mUSBDevices.erase(*aIt);
    78747863        LogFlowFunc(("Detached device {%RTuuid}\n", pUSBDevice->id().raw()));
     7864
     7865        alock.release();
    78757866
    78767867        /* notify callbacks */
     
    82638254 *
    82648255 * @param   pVM     The VM handle.
    8265  *
    8266  * @note The caller must lock this object for writing.
    82678256 */
    82688257HRESULT Console::captureUSBDevices(PVM pVM)
     
    82718260
    82728261    /* sanity check */
    8273     ComAssertRet(isWriteLockOnCurrentThread(), E_FAIL);
     8262    AssertReturn(!isWriteLockOnCurrentThread(), E_FAIL);
     8263    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    82748264
    82758265    /* If the machine has an USB controller, ask the USB proxy service to
     
    82828272         * us back from under its lock (e.g. onUSBDeviceAttach()) which would
    82838273         * produce an inter-process dead-lock otherwise. */
    8284         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    82858274        alock.release();
    82868275
     
    83018290 * Detach all USB device which are attached to the VM for the
    83028291 * purpose of clean up and such like.
    8303  *
    8304  * @note The caller must lock this object for writing.
    83058292 */
    83068293void Console::detachAllUSBDevices(bool aDone)
     
    83098296
    83108297    /* sanity check */
    8311     AssertReturnVoid(isWriteLockOnCurrentThread());
     8298    AssertReturnVoid(!isWriteLockOnCurrentThread());
     8299    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    83128300
    83138301    mUSBDevices.clear();
     
    83168304     * us back from under its lock (e.g. onUSBDeviceAttach()) which would
    83178305     * produce an inter-process dead-lock otherwise. */
    8318     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    83198306    alock.release();
    83208307
     
    84158402            if (fMatched)
    84168403            {
     8404                alock.release();
    84178405                hrc = onUSBDeviceAttach(pUSBDevice, NULL, fMaskedIfs);
     8406                alock.acquire();
    84188407
    84198408                /// @todo (r=dmik) warning reporting subsystem
     
    84808469            Bstr uuid;
    84818470            pUSBDevice->COMGETTER(Id)(uuid.asOutParam());
     8471            alock.release();
    84828472            onUSBDeviceDetach(uuid.raw(), NULL);
     8473            alock.acquire();
    84838474        }
    84848475
     
    87158706                }
    87168707
     8708                /* release the lock before a lengthy operation */
     8709                alock.release();
     8710
    87178711                /*
    87188712                 * Capture USB devices.
     
    87208714                rc = pConsole->captureUSBDevices(pVM);
    87218715                if (FAILED(rc)) break;
    8722 
    8723                 /* release the lock before a lengthy operation */
    8724                 alock.release();
    87258716
    87268717                /* Load saved state? */
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