VirtualBox

Changeset 24969 in vbox for trunk/src


Ignore:
Timestamp:
Nov 25, 2009 4:56:40 PM (15 years ago)
Author:
vboxsync
Message:

Main,VBoxManage: Check for timeout in the progress object (simple polling) and made use of this in the controlvm teleport VBoxManage command.

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r24903 r24969  
    797797            uint32_t    uMaxDowntime = 250 /*ms*/;
    798798            uint32_t    uPort        = UINT32_MAX;
     799            uint32_t    cMsTimeout   = 0;
    799800            Bstr        bstrPassword("");
    800801            static const RTGETOPTDEF s_aTeleportOptions[] =
     
    804805                { "--maxdowntime", 'd', RTGETOPT_REQ_UINT32 },
    805806                { "--port",        'p', RTGETOPT_REQ_UINT32 }, /** @todo RTGETOPT_FLAG_MANDATORY */
    806                 { "--password",    'P', RTGETOPT_REQ_STRING }
     807                { "--password",    'P', RTGETOPT_REQ_STRING },
     808                { "--timeout",     't', RTGETOPT_REQ_UINT32 }
    807809            };
    808810            RTGETOPTSTATE GetOptState;
     
    819821                    case 'p': uPort         = Value.u32; break;
    820822                    case 'P': bstrPassword  = Value.psz; break;
     823                    case 't': cMsTimeout    = Value.u32; break;
    821824                    default:
    822825                        errorGetOpt(USAGE_CONTROLVM, ch, &Value);
     
    830833            ComPtr<IProgress> progress;
    831834            CHECK_ERROR_BREAK(console, Teleport(bstrHostname, uPort, bstrPassword, uMaxDowntime, progress.asOutParam()));
     835
     836            if (cMsTimeout)
     837            {
     838                rc = progress->COMSETTER(Timeout)(cMsTimeout);
     839                if (FAILED(rc) && rc != VBOX_E_INVALID_OBJECT_STATE)
     840                    CHECK_ERROR_BREAK(progress, COMSETTER(Timeout)(cMsTimeout)); /* lazyness */
     841            }
     842
    832843            rc = showProgress(progress);
    833844            if (FAILED(rc))
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r24961 r24969  
    287287    return dPercent;
    288288}
     289
     290/**
     291 * Internal helper for automatically timing out the operation.
     292 *
     293 * The caller should hold the object write lock.
     294 */
     295void ProgressBase::checkForAutomaticTimeout(void)
     296{
     297    if (   m_cMsTimeout
     298        && mCancelable
     299        && !mCanceled
     300        && RTTimeMilliTS() - m_ullTimestamp > m_cMsTimeout
     301       )
     302        Cancel();
     303}
     304
    289305
    290306STDMETHODIMP ProgressBase::COMGETTER(TimeRemaining)(LONG *aTimeRemaining)
     
    328344    CheckComRCReturnRC(autoCaller.rc());
    329345
    330     AutoReadLock alock(this);
     346    checkForAutomaticTimeout();
     347
     348    /* checkForAutomaticTimeout requires a write lock. */
     349    AutoWriteLock alock(this);
    331350
    332351    if (mCompleted && SUCCEEDED(mResultCode))
     
    346365    }
    347366
     367    checkForAutomaticTimeout();
     368
    348369    return S_OK;
    349370}
     
    562583    AutoWriteLock alock(this);
    563584
     585    checkForAutomaticTimeout();
    564586    if (mCanceled)
    565587        return false;
     
    952974    AssertReturn(aPercent <= 100, E_INVALIDARG);
    953975
     976    checkForAutomaticTimeout();
    954977    if (mCancelable && mCanceled)
    955978    {
     
    957980        return E_FAIL;
    958981    }
    959     else
    960         AssertReturn(!mCompleted && !mCanceled, E_FAIL);
     982    AssertReturn(!mCompleted && !mCanceled, E_FAIL);
    961983
    962984    m_ulOperationPercent = aPercent;
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r24961 r24969  
    9999
    100100protected:
     101    void checkForAutomaticTimeout(void);
    101102
    102103#if !defined (VBOX_COM_INPROC)
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