VirtualBox

Changeset 911 in vbox


Ignore:
Timestamp:
Feb 14, 2007 6:41:37 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18636
Message:

Main: Fixed an assertion hit when opening the VDM dialog from the console window (for example, to mount a CD media) of a running VM or doing any other media accessibility check on it that could leave to undefined behavior in the release builds.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r362 r911  
    564564/**
    565565 *  Checks basic accessibility of this hard disk only (w/o parents).
    566  *  Must be always called by every reimplementation in the first place.
    567  *
    568  *  @param aAccessError on output, a null string indicates the hard disk is
     566 *  Must be always called by every HardDisk::getAccessible() reimplementation
     567 *  in the first place.
     568 *
     569 *  When @a aCheckBusy is true, this method checks that mBusy = false and
     570 *  mReaders = 0 (and returns an appropriate error if not). This lets
     571 *  reimplementations successfully call setBusy() to lock the disk for the
     572 *  duration of the check if they need. Note that in this case, the
     573 *  reimplementation must enter the object lock before calling this method
     574 *  and not leave it before calling setBusy() to avoid race condition.
     575 *
     576 *  @param aAccessError On output, a null string indicates the hard disk is
    569577 *                      accessible, otherwise contains a message describing
    570578 *                      the reason of inaccessibility.
    571  */
    572 HRESULT HardDisk::getAccessible (Bstr &aAccessError)
    573 {
    574     AutoLock alock (this);
    575     CHECK_READY();
    576 
    577     if (mBusy)
    578     {
    579         aAccessError =
    580             Utf8StrFmt (tr ("Hard disk '%ls' is being used by another task"),
    581                         toString().raw());
    582     }
    583     else
    584         aAccessError.setNull();
     579 *  @param aCheckBusy   Whether to do the busy check or not.
     580 */
     581HRESULT HardDisk::getBaseAccessible (Bstr &aAccessError,
     582                                     bool aCheckBusy /* = false */)
     583{
     584    AutoLock alock (this);
     585    CHECK_READY();
     586
     587    aAccessError.setNull();
     588
     589    if (aCheckBusy)
     590    {
     591        if (mBusy)
     592        {
     593            aAccessError = Utf8StrFmt (
     594                tr ("Hard disk '%ls' is being exclusively used by another task"),
     595                toString().raw());
     596        }
     597        else if (mReaders > 0)
     598        {
     599            aAccessError = Utf8StrFmt (
     600                tr ("Hard disk '%ls' is being used by another task (%d readers)"),
     601                toString().raw(), mReaders);
     602        }
     603    }
    585604
    586605    return S_OK;
     
    15651584
    15661585    /* check the basic accessibility */
    1567     HRESULT rc = HardDisk::getAccessible (aAccessError);
     1586    HRESULT rc = getBaseAccessible (aAccessError, true /* aCheckBusy */);
    15681587    if (FAILED (rc) || !aAccessError.isNull())
    15691588        return rc;
     
    30073026
    30083027    /* check the basic accessibility */
    3009     HRESULT rc = HardDisk::getAccessible (aAccessError);
     3028    HRESULT rc = getBaseAccessible (aAccessError);
    30103029    if (FAILED (rc) || !aAccessError.isNull())
    30113030        return rc;
  • trunk/src/VBox/Main/include/HardDiskImpl.h

    r749 r911  
    129129    ComObjPtr <HardDisk> root() const;
    130130
     131    HRESULT getBaseAccessible (Bstr &aAccessError, bool aCheckBusy = false);
     132
    131133    // virtual methods that need to be [re]implemented by every subclass
    132134
    133135    virtual HRESULT trySetRegistered (BOOL aRegistered);
    134     virtual HRESULT getAccessible (Bstr &aAccessError);
     136    virtual HRESULT getAccessible (Bstr &aAccessError) = 0;
    135137
    136138    virtual HRESULT saveSettings (CFGNODE aHDNode, CFGNODE aStorageNode) = 0;
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