VirtualBox

Changeset 107254 in vbox


Ignore:
Timestamp:
Dec 9, 2024 1:09:34 PM (7 weeks ago)
Author:
vboxsync
Message:

bugref:10806. Added member TrackedObjectData:m_fLifeTimeExpired, the getters isIdleTimeStarted() and isLifeTimeExpired(), function TrackedObjectsCollector::updateObj(). jiraref:VBP-1459.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ObjectsTracker.h

    r107240 r107254  
    145145    }
    146146
     147    inline bool isIdleTimeStarted() const
     148    {
     149        return m_fIdleTimeStart;
     150    }
     151
     152    inline bool isLifeTimeExpired() const
     153    {
     154        return m_fLifeTimeExpired;
     155    }
     156
    147157    com::Utf8Str updateLastAccessTime();
    148158    com::Utf8Str initIdleTime();
     
    156166    com::Utf8Str m_componentName;
    157167    RTTIMESPEC m_creationTime;//creation time
     168    RTTIMESPEC m_deletionTime;//deletion time (m_creationTime + m_lifeTime + m_idleTime)
    158169    RTTIMESPEC m_idleTimeStart;//idle time beginning (ref counter is 1)
    159     RTTIMESPEC m_deletionTime;//deletion time (m_creationTime + m_lifeTime + m_idleTime)
    160170    RTTIMESPEC m_lastAccessTime;//last access time
    161171    uint64_t m_lifeTime;//lifetime after creation in seconds, 0 - live till the VBoxSVC lives
    162172    uint64_t m_idleTime;//lifetime after out of usage in seconds, 0 - keep forever
    163173    bool m_fIdleTimeStart;//when ref counter of m_pIface is 1 or m_lifeTime exceeded
     174    bool m_fLifeTimeExpired;//set to True only one time during the whole object life
    164175    TrackedObjectState_T m_state;
    165176    ComPtr<IUnknown> m_pIface;//keeps a reference to a tracked object
     
    200211                    uint64_t afterLifeTime,
    201212                    IUnknown* ptrIface);
     213
     214    HRESULT updateObj (const TrackedObjectData& aObjData);
    202215
    203216    HRESULT getObj (const com::Utf8Str &aObjId,
  • trunk/src/VBox/Main/src-all/ObjectsTracker.cpp

    r107240 r107254  
    6464    m_idleTime(aIdleTime),
    6565    m_fIdleTimeStart(false),
     66    m_fLifeTimeExpired(false),
    6667    m_pIface(aPtr)
    6768{
     
    8788        m_idleTimeStart = that.m_idleTimeStart;
    8889        m_fIdleTimeStart = that.m_fIdleTimeStart;
     90        m_fLifeTimeExpired = that.m_fLifeTimeExpired;
    8991        m_state = that.m_state;
    9092    }
     
    116118        m_idleTimeStart = that.m_idleTimeStart;
    117119        m_fIdleTimeStart = that.m_fIdleTimeStart;
     120        m_fLifeTimeExpired = that.m_fLifeTimeExpired;
    118121        m_state = that.m_state;
    119122    }
     
    140143        RTTimeNow(unconst(&m_idleTimeStart));
    141144        m_fIdleTimeStart = true;
     145        m_fLifeTimeExpired = true;
    142146    }
    143147
     
    325329    /* increase the counter */
    326330    ++m_Added;
     331
     332    /* Leave critical section here */
     333    RTCritSectLeave(&m_CritSectData);
     334
     335    return hrc;
     336}
     337
     338
     339HRESULT TrackedObjectsCollector::updateObj (const TrackedObjectData& aObjData)
     340{
     341    LogFlowFuncEnter();
     342
     343    HRESULT hrc = S_OK;
     344    int vrc = i_checkInitialization();
     345    if (RT_FAILURE(vrc))
     346        return VBOX_E_INVALID_OBJECT_STATE;
     347
     348    /* Enter critical section here */
     349    RTCritSectEnter(&m_CritSectData);
     350
     351    std::pair < std::set<com::Utf8Str>::iterator, bool > opRes = m_trackedObjectIds.insert(aObjData.objectIdStr());
     352
     353    /*
     354     * The case for updating the tracked object data.
     355     * The Id is presented in the m_trackedObjectIds. The original object is removed from m_trackedObjectsData.
     356     */
     357    if (!opRes.second)
     358    {
     359        Log2(("UPDATING TrackedObjectData:\n state %i\n object Id %s\n class IID %s\n life time %i\n idle time %i"
     360                "\n life time expired - %s\n idle time started - %s\n",
     361                aObjData.state(),
     362                aObjData.objectIdStr().c_str(),
     363                aObjData.classIIDStr().c_str(),
     364                aObjData.lifeTime(),
     365                aObjData.idleTime(),
     366                (aObjData.isLifeTimeExpired() == true ? "True" : "False"),
     367                (aObjData.isIdleTimeStarted() == true ? "True" : "False")));
     368
     369        m_trackedObjectsData.erase(aObjData.objectIdStr().c_str());
     370        /* decrease the counter */
     371        --m_Added;
     372
     373        /* Data is stored in the m_trackedObjectsData under the passed Id. */
     374        m_trackedObjectsData.insert(std::make_pair(aObjData.objectIdStr(), aObjData));
     375
     376        /* increase the counter */
     377        ++m_Added;
     378    }
     379    else
     380    {
     381        Log2(("UPDATING failed because the object Id %s hasn't existed.\n", aObjData.objectIdStr().c_str()));
     382        m_trackedObjectIds.erase(aObjData.objectIdStr());
     383    }
    327384
    328385    /* Leave critical section here */
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