VirtualBox

Changeset 31018 in vbox


Ignore:
Timestamp:
Jul 22, 2010 4:59:41 PM (15 years ago)
Author:
vboxsync
Message:

Events: handle dead listeners better

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/defs.h

    r30739 r31018  
    264264#define SUCCEEDED_WARNING(rc)   (NS_SUCCEEDED (rc) && (rc) != NS_OK)
    265265
    266 #define FAILED_DEAD_INTERFACE(rc) (false) /**< @todo */
     266#define FAILED_DEAD_INTERFACE(rc)  ( (rc) == NS_ERROR_ABORT )
    267267
    268268#define IUnknown nsISupports
  • trunk/src/VBox/Main/EventImpl.cpp

    r30913 r31018  
    6161#include <iprt/critsect.h>
    6262#include <iprt/asm.h>
     63#include <iprt/time.h>
    6364
    6465#include <VBox/com/array.h>
     
    576577    PassiveQueue                  mQueue;
    577578    int32_t                       mRefCnt;
     579    uint64_t                      mLastRead;
    578580
    579581public:
     
    734736        ::RTCritSectInit(&mcsQLock);
    735737        ::RTSemEventCreate (&mQEvent);
     738        mLastRead = RTTimeMilliTS();
    736739    }
    737740}
     
    805808{
    806809    AssertMsg(!mActive, ("must be passive\n"));
     810
    807811    // put an event the queue
    808812    ::RTCritSectEnter(&mcsQLock);
     813
     814    // If there was no events reading from the listener for the long time,
     815    // and events keep coming we shall unregister it.
     816    if ((mQueue.size() > 200) && ((RTTimeMilliTS() - mLastRead) > 60 * 1000))
     817    {
     818        ::RTCritSectLeave(&mcsQLock);
     819        return E_ABORT;
     820    }
     821
    809822    mQueue.push_back(aEvent);
    810823    ::RTCritSectLeave(&mcsQLock);
     
    826839
    827840    ::RTCritSectEnter(&mcsQLock);
     841
     842    mLastRead = RTTimeMilliTS();
     843
    828844    if (mQueue.empty())    {
    829845        ::RTCritSectLeave(&mcsQLock);
     
    10261042            cbRc = record.obj()->process(aEvent, aWaitable, pit, alock);
    10271043
    1028             if (FAILED_DEAD_INTERFACE(cbRc))
     1044            if (FAILED_DEAD_INTERFACE(cbRc) || (cbRc == E_ABORT))
    10291045            {
    10301046                Listeners::iterator lit = m->mListeners.find(record.obj()->mListener);
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