VirtualBox

Changeset 3664 in vbox for trunk/src


Ignore:
Timestamp:
Jul 17, 2007 4:21:29 AM (18 years ago)
Author:
vboxsync
Message:

ugly state mess hacking.

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

Legend:

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

    r3566 r3664  
    612612                        /* couldn't capture the device, will report an error */
    613613                        wasCapture = true;
    614        
     614
    615615                        Assert (!mMachine.isNull());
    616        
     616
    617617                        /// @todo more detailed error message depending on the state?
    618618                        //  probably need some error code/string from the USB proxy itself
    619        
     619
    620620                        requestRC = E_FAIL;
    621621                        errorText = Utf8StrFmt (
     
    630630                {
    631631                    Assert (mMachine.isNull());
    632        
     632
    633633                    if (mState == USBDeviceState_USBDeviceHeld)
    634634                    {
     
    674674
    675675        /*
    676          * The device has reappeared while the detach operation is still in 
     676         * The device has reappeared while the detach operation is still in
    677677         * progress, just clear the pending operation and leave the machine as is.
    678678         */
     
    787787        case kDetachingPendingAttach:
    788788        case kDetachingPendingAttachFilters:
     789            LogFlowThisFunc (("cancelling reattach in state %d\n", mPendingStateEx));
    789790            mMachine.setNull();
    790791            mPendingStateEx = kNothingPending;
     
    943944                            bool aIsStrict /* = true */)
    944945{
    945     /* The non-strict checks tries as best as it can to distiguish between 
     946    /* The non-strict checks tries as best as it can to distiguish between
    946947       different physical devices of the same product. Unfortunately this
    947948       isn't always possible and we might end up a bit confused in rare cases... */
     
    11071108                case USBDeviceState_USBDeviceAvailable:
    11081109                    return false;
    1109 #ifdef __LINUX__ /* Hack for /proc/bus/usb/devices not necessarily putting up a driver. */
     1110#if defined(RT_OS_LINUX)  /* Hack for /proc/bus/usb/devices not necessarily putting up a driver. */ \
     1111 || defined(RT_OS_DARWIN) /* We're a bit clueless as to the exact device state, just like linux. */
    11101112                case USBDeviceState_USBDeviceCaptured:
    1111                     if (!mIsStatePending)
     1113                    if (    !mIsStatePending
     1114                        ||  mPendingStateEx != kNothingPending)
    11121115                        return false;
    11131116                    isImportant = true;
     
    11341137                case USBDeviceState_USBDeviceHeld:
    11351138                    return false;
    1136 #ifdef __WIN__
    11371139                case USBDeviceState_USBDeviceCaptured:
    11381140                    if (!mIsStatePending)
    11391141                        return false;
    11401142                    /* no break */
    1141 #endif
    11421143                default:
    11431144                    LogFlowThisFunc (("%d -> %d\n",
     
    11771178/**
    11781179 *  Checks for timeout of any pending async operation.
    1179  * 
    1180  *  The caller must write lock the object prior to calling 
     1180 *
     1181 *  The caller must write lock the object prior to calling
    11811182 *  this method.
    11821183 */
     
    12001201}
    12011202
    1202 /** 
    1203  *  This method is called by the USB proxy and Host to work the 
     1203/**
     1204 *  This method is called by the USB proxy and Host to work the
    12041205 *  logical reconnection operation.
    1205  * 
     1206 *
    12061207 *  @param  aStage      kDeatchingPendingDetach, kDeatchingPendingDetachFilters,
    12071208 *                      kDetachingPendingAttach or kDetachingPendingAttachFilters.
    1208  * 
     1209 *
    12091210 *  @returns Success indicator.
    12101211 */
     
    12201221            mIsStatePending = true;
    12211222            mPendingSince = RTTimeNanoTS();
     1223            LogFlowThisFunc (("pending detach\n"));
    12221224            break;
    12231225
     
    12251227            AssertReturn (mIsStatePending, false);
    12261228            AssertReturn (mPendingStateEx == kDetachingPendingDetach, false);
     1229            LogFlowThisFunc (("pending detach+filters\n"));
    12271230            break;
    12281231
     
    12301233            AssertReturn (mIsStatePending, false);
    12311234            AssertReturn (mPendingStateEx == kDetachingPendingDetach, false);
     1235            LogFlowThisFunc (("pending attach\n"));
    12321236            break;
    12331237
    12341238        case kDetachingPendingAttachFilters:
    12351239            AssertReturn (mIsStatePending, false);
    1236             AssertReturn (   mPendingStateEx == kDetachingPendingAttach 
     1240            AssertReturn (   mPendingStateEx == kDetachingPendingAttach
    12371241                          || mPendingStateEx == kDetachingPendingDetachFilters, false);
     1242            LogFlowThisFunc (("pending attach+filters\n"));
    12381243            break;
    12391244
  • trunk/src/VBox/Main/USBProxyService.cpp

    r3571 r3664  
    196196        pDevices = sortDevices (pDevices);
    197197
    198         /* 
     198        /*
    199199         * We need to lock the host object for writing because
    200200         * a) the subsequent code may call Host methods that require a write
     
    202202         * b) we will lock HostUSBDevice objects below and want to make sure
    203203         *    the lock order is always the same (Host, HostUSBDevice, as
    204          *    expected by Host) to avoid cross-deadlocks 
     204         *    expected by Host) to avoid cross-deadlocks
    205205         */
    206206        AutoLock hostLock (mHost);
     
    219219                DevPtr = *It;
    220220
    221             /* 
     221            /*
    222222             * Assert that the object is still alive (we still reference it in
    223              * the collection and we're the only one who calls uninit() on it 
     223             * the collection and we're the only one who calls uninit() on it
    224224             */
    225225            HostUSBDevice::AutoCaller devCaller (DevPtr.isNull() ? NULL : DevPtr);
    226226            AssertComRC (devCaller.rc());
    227227
    228             /* 
     228            /*
    229229             * Lock the device object since we will read/write it's
    230              * properties. All Host callbacks also imply the object is locked. 
     230             * properties. All Host callbacks also imply the object is locked.
    231231             */
    232232            AutoLock devLock (DevPtr.isNull() ? NULL : DevPtr);
     
    248248            {
    249249                /*
    250                  * The device still there, update the state and move on. The PUSBDEVICE 
     250                 * The device still there, update the state and move on. The PUSBDEVICE
    251251                 * structure is eaten by updateDeviceState / HostUSBDevice::updateState().
    252252                 */
     
    579579    AssertReturn (aDevice->isLockedOnCurrentThread(), false);
    580580
    581     return aDevice->updateState (aUSBDevice);
     581    bool fRc = aDevice->updateState (aUSBDevice);
     582    /* A little hack to work around state quirks wrt detach/reattach. */
     583    if (    !fRc
     584        &&  aDevice->isStatePending()
     585        &&  (   aDevice->pendingStateEx() == HostUSBDevice::kDetachingPendingAttach
     586             || aDevice->pendingStateEx() == HostUSBDevice::kDetachingPendingAttachFilters))
     587        fRc = true;
     588    return fRc;
    582589}
    583590
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