VirtualBox

Changeset 49938 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Dec 16, 2013 5:13:59 PM (11 years ago)
Author:
vboxsync
Message:

Main/src-server/win/HostPowerWin.cpp: fix long standing bug which caused VBoxSVC to hang around for 5 seconds as the thread termination notification wasn't posted properly
Main/src-server/win/svcmain.cpp: reduced "just in case" sleep, shouldn't be necessary at all, when threads using COM are present the server shouldn't ever get to this place
Runtime/common/log/log.cpp: if there are sharing problems with the log file to be opened, wait for up to 10 seconds, maybe the previous user goes away (helps with VBoxSVC release log which can cause trouble, when the previous process is not quite terminated and some API client triggers the launch of a new one), effectively Windows only

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r48935 r49938  
    293293    { "user",     sizeof("user"    ) - 1,  RTLOGDEST_USER },
    294294};
     295
     296/**
     297 * Log rotation backoff table, important on Windows host, especially for
     298 * VBoxSVC release logging. Only a medium term solution, until a proper fix
     299 * for log file handling is available. 10 seconds total.
     300 */
     301static const uint32_t s_aLogBackoff[] =
     302{ 10, 10, 10, 20, 50, 100, 200, 200, 200, 200, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000 };
    295303
    296304
     
    26102618static int rtlogFileOpen(PRTLOGGER pLogger, char *pszErrorMsg, size_t cchErrorMsg)
    26112619{
    2612     uint32_t fOpen = RTFILE_O_WRITE | RTFILE_O_DENY_WRITE;
     2620    uint32_t fOpen = RTFILE_O_WRITE | RTFILE_O_DENY_NONE;
    26132621    if (pLogger->fFlags & RTLOGFLAGS_APPEND)
    26142622        fOpen |= RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND;
     
    26182626        fOpen |= RTFILE_O_WRITE_THROUGH;
    26192627
    2620     int rc = RTFileOpen(&pLogger->pInt->hFile, pLogger->pInt->szFilename, fOpen);
     2628    int rc;
     2629    int cBackoff = 0;
     2630    do
     2631    {
     2632        rc = RTFileOpen(&pLogger->pInt->hFile, pLogger->pInt->szFilename, fOpen);
     2633        if (rc == VERR_SHARING_VIOLATION)
     2634        {
     2635            if (cBackoff >= RT_ELEMENTS(s_aLogBackoff))
     2636                break;
     2637            RTThreadSleep(s_aLogBackoff[cBackoff]);
     2638            cBackoff++;
     2639        }
     2640    }
     2641    while (rc == VERR_SHARING_VIOLATION);
    26212642    if (RT_FAILURE(rc))
    26222643    {
     
    27102731            char szNewName[sizeof(pLogger->pInt->szFilename) + 32];
    27112732            RTStrPrintf(szNewName, sizeof(szNewName), "%s.%u", pLogger->pInt->szFilename, i + 1);
    2712             if (   RTFileRename(szOldName, szNewName, RTFILEMOVE_FLAGS_REPLACE)
    2713                 == VERR_FILE_NOT_FOUND)
     2733
     2734
     2735
     2736            int rc;
     2737            int cBackoff = 0;
     2738            do
     2739            {
     2740                rc = RTFileRename(szOldName, szNewName, RTFILEMOVE_FLAGS_REPLACE);
     2741                if (rc == VERR_SHARING_VIOLATION)
     2742                {
     2743                    if (cBackoff >= RT_ELEMENTS(s_aLogBackoff))
     2744                        break;
     2745                    RTThreadSleep(s_aLogBackoff[cBackoff]);
     2746                    cBackoff++;
     2747                }
     2748            }
     2749            while (rc == VERR_SHARING_VIOLATION);
     2750            if (rc == VERR_FILE_NOT_FOUND)
    27142751                RTFileDelete(szNewName);
    27152752        }
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