VirtualBox

Changeset 61361 in vbox


Ignore:
Timestamp:
Jun 1, 2016 7:59:04 AM (8 years ago)
Author:
vboxsync
Message:

Main/webservice: switch to using monotonic time for sessin expiration, and add statistics logging for session and MOR count

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r60865 r61361  
    14461446    WEBDEBUG(("Watchdog thread started\n"));
    14471447
     1448    uint32_t tNextStat = 0;
     1449
    14481450    while (g_fKeepRunning)
    14491451    {
     
    14511453        RTThreadSleep(g_iWatchdogCheckInterval * 1000);
    14521454
    1453         time_t                      tNow;
    1454         time(&tNow);
     1455        uint32_t tNow = RTTimeProgramSecTS();
    14551456
    14561457        // we're messing with websessions, so lock them
     
    14821483                pSystemProperties->COMSETTER(WebServiceAuthLibrary)(com::Bstr(g_pcszAuthentication).raw());
    14831484        }
     1485
     1486        // Log some MOR usage statistics every 5 minutes, but only if there's
     1487        // something worth logging (at least one reference or a transition to
     1488        // zero references). Avoids useless log spamming in idle webservice.
     1489        if (tNow >= tNextStat)
     1490        {
     1491            size_t cMOR = 0;
     1492            it = g_mapWebsessions.begin();
     1493            itEnd = g_mapWebsessions.end();
     1494            while (it != itEnd)
     1495            {
     1496                cMOR += it->second->CountRefs();
     1497                ++it;
     1498            }
     1499            static bool fLastZero = false;
     1500            if (cMOR || !fLastZero)
     1501                LogRel(("Statistics: %zu websessions, %zu references\n",
     1502                        g_mapWebsessions.size(), cMOR));
     1503            fLastZero = (cMOR == 0);
     1504            while (tNextStat <= tNow)
     1505                tNextStat += 5 * 60; /* 5 minutes */
     1506        }
    14841507    }
    14851508
     
    20122035void WebServiceSession::touch()
    20132036{
    2014     time(&_tLastObjectLookup);
     2037    _tLastObjectLookup = RTTimeProgramSecTS();
     2038}
     2039
     2040/**
     2041 * Counts the number of managed object references in this websession.
     2042 */
     2043size_t WebServiceSession::CountRefs()
     2044{
     2045    return _pp->_mapManagedObjectsById.size();
    20152046}
    20162047
  • trunk/src/VBox/Main/webservice/vboxweb.h

    r59654 r61361  
    33 *      header file for "real" web server code.
    44 *
    5  * Copyright (C) 2006-2015 Oracle Corporation
     5 * Copyright (C) 2006-2016 Oracle Corporation
    66 *
    77 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    104104        bool                        _fDestructing;
    105105
    106         time_t                      _tLastObjectLookup;
     106        uint32_t                    _tLastObjectLookup;
    107107
    108108        // hide the copy constructor because we're not copyable
     
    133133        void touch();
    134134
    135         time_t getLastObjectLookup() const
     135        uint32_t getLastObjectLookup() const
    136136        {
    137137            return _tLastObjectLookup;
     
    140140        static WebServiceSession* findWebsessionFromRef(const WSDLT_ID &id);
    141141
    142         void DumpRefs();
     142        size_t CountRefs();
    143143};
    144144
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