VirtualBox

Changeset 29041 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 4, 2010 8:13:41 PM (15 years ago)
Author:
vboxsync
Message:

VBoxService/Control: Use critsects also, logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp

    r28943 r29041  
    178178        if (RT_FAILURE(rc))
    179179        {
    180             VBoxServiceError("Control: Error while sending real-time output data, rc=%Rrc, cbRead=%u, CID=%u, PID=%u\n",
     180            VBoxServiceError("ControlExec: Error while sending real-time output data, rc=%Rrc, cbRead=%u, CID=%u, PID=%u\n",
    181181                             rc, cbRead, pThread->uClientID, pData->uPID);
    182182        }
     
    274274     * and that it's now OK to send input to the process.
    275275     */
    276     VBoxServiceVerbose(3, "Control: Process started: PID=%u, CID=%u, User=%s, PW=%s\n",
     276    VBoxServiceVerbose(3, "ControlExec: Process started: PID=%u, CID=%u, User=%s, PW=%s\n",
    277277                       pData->uPID, pThread->uContextID, pData->pszUser, pData->pszPassword);
    278278    rc = VbglR3GuestCtrlExecReportStatus(pThread->uClientID, pThread->uContextID,
     
    370370            if (cMsElapsed >= cMillies)
    371371            {
    372                 VBoxServiceVerbose(3, "Control: Process timed out (%ums elapsed > %ums timeout), killing ...", cMsElapsed, cMillies);
     372                VBoxServiceVerbose(3, "ControlExec: Process timed out (%ums elapsed > %ums timeout), killing ...", cMsElapsed, cMillies);
    373373
    374374                fProcessTimedOut = true;
     
    435435        if (     fProcessTimedOut  && !fProcessAlive && MsProcessKilled != UINT64_MAX)
    436436        {
     437            VBoxServiceVerbose(3, "ControlExec: Process timed out and got killed\n");
    437438            uStatus = PROC_STS_TOK;
    438439        }
    439440        else if (fProcessTimedOut  &&  fProcessAlive && MsProcessKilled != UINT64_MAX)
    440441        {
     442            VBoxServiceVerbose(3, "ControlExec: Process timed out and did *not* get killed\n");
    441443            uStatus = PROC_STS_TOA;
    442444        }
    443445        else if (pThread->fShutdown && (fProcessAlive || MsProcessKilled != UINT64_MAX))
    444446        {
     447            VBoxServiceVerbose(3, "ControlExec: Process got terminated because system/service is going stopping\n");
    445448            uStatus = PROC_STS_DWN; /* Service is stopping, process was killed. */
    446449        }
    447450        else if (fProcessAlive)
    448451        {
    449             VBoxServiceError("Control: Process is alive when it should not!\n");
     452            VBoxServiceError("ControlExec: Process is alive when it should not!\n");
    450453        }
    451454        else if (MsProcessKilled != UINT64_MAX)
    452455        {
    453             VBoxServiceError("Control: Process has been killed when it should not!\n");
     456            VBoxServiceError("ControlExec: Process has been killed when it should not!\n");
    454457        }
    455458        else if (ProcessStatus.enmReason == RTPROCEXITREASON_NORMAL)
    456459        {
     460            VBoxServiceVerbose(3, "ControlExec: Process ended with RTPROCEXITREASON_NORMAL\n");
     461
    457462            uStatus = PROC_STS_TEN;
    458463            uFlags = ProcessStatus.iStatus;
     
    460465        else if (ProcessStatus.enmReason == RTPROCEXITREASON_SIGNAL)
    461466        {
     467            VBoxServiceVerbose(3, "ControlExec: Process ended with RTPROCEXITREASON_SIGNAL\n");
     468
    462469            uStatus = PROC_STS_TES;
    463470            uFlags = ProcessStatus.iStatus;
     
    465472        else if (ProcessStatus.enmReason == RTPROCEXITREASON_ABEND)
    466473        {
     474            VBoxServiceVerbose(3, "ControlExec: Process ended with RTPROCEXITREASON_ABEND\n");
     475
    467476            uStatus = PROC_STS_TEA;
    468477            uFlags = ProcessStatus.iStatus;
     
    470479        else
    471480        {
    472             VBoxServiceError("Control: Process has reached an undefined status!\n");
    473         }
    474 
    475         VBoxServiceVerbose(3, "Control: Process ended: PID=%u, CID=%u, Status=%u, Flags=%u\n",
     481            VBoxServiceError("ControlExec: Process has reached an undefined status!\n");
     482        }
     483
     484        VBoxServiceVerbose(3, "ControlExec: Process ended: PID=%u, CID=%u, Status=%u, Flags=%u\n",
    476485                           pData->uPID, pThread->uContextID, uStatus, uFlags);
    477486        rc = VbglR3GuestCtrlExecReportStatus(pThread->uClientID, pThread->uContextID,
     
    480489    }
    481490    RTMemFree(StdInBuf.pch);
    482     VBoxServiceVerbose(3, "Control: Process loop ended with rc=%Rrc\n", rc);
     491    VBoxServiceVerbose(3, "ControlExec: Process loop ended with rc=%Rrc\n", rc);
    483492    return rc;
    484493}
     
    545554    pBuf->cbRead = 0;
    546555
    547     return RTSemMutexCreate(&pBuf->mtx);
     556    return RTCritSectInit(&pBuf->CritSect);
    548557}
    549558
     
    559568        pBuf->cbRead = 0;
    560569    }
    561     return RTSemMutexDestroy(pBuf->mtx);
     570    return RTCritSectDelete(&pBuf->CritSect);
    562571}
    563572
     
    568577    AssertPtr(pcbToRead);
    569578
    570     int rc = RTSemMutexRequest(pBuf->mtx, RT_INDEFINITE_WAIT);
     579    int rc = RTCritSectEnter(&pBuf->CritSect);
    571580    if (RT_SUCCESS(rc))
    572581    {   
     
    588597            *pcbToRead = 0;
    589598        }
    590         rc = RTSemMutexRelease(pBuf->mtx);
     599        rc = RTCritSectLeave(&pBuf->CritSect);
    591600    }
    592601    return rc;
     
    598607    AssertPtr(pBuf);
    599608
    600     int rc = RTSemMutexRequest(pBuf->mtx, RT_INDEFINITE_WAIT);
     609    int rc = RTCritSectEnter(&pBuf->CritSect);
    601610    if (RT_SUCCESS(rc))
    602611    {   
     
    621630        else
    622631            rc = VERR_NO_MEMORY;
    623         int rc2 = RTSemMutexRelease(pBuf->mtx);
     632        int rc2 = RTCritSectLeave(&pBuf->CritSect);
    624633        if (RT_SUCCESS(rc))
    625634            rc = rc2;
     
    759768     */
    760769    RTThreadUserSignal(RTThreadSelf());
    761     VBoxServiceVerbose(3, "Control: Thread of process \"%s\" started\n", pData->pszCmd);
     770    VBoxServiceVerbose(3, "ControlExec: Thread of process \"%s\" started\n", pData->pszCmd);
    762771
    763772    int rc = VbglR3GuestCtrlConnect(&pThread->uClientID);
    764773    if (RT_FAILURE(rc))
    765774    {
    766         VBoxServiceError("Control: Thread failed to connect to the guest control service, aborted! Error: %Rrc\n", rc);
     775        VBoxServiceError("ControlExec: Thread failed to connect to the guest control service, aborted! Error: %Rrc\n", rc);
    767776        return rc;
    768777    }
     
    863872                                                                              NULL /* pvData */, 0 /* cbData */);
    864873                                    if (RT_FAILURE(rc2))
    865                                         VBoxServiceError("Control: Could not report process start error! Error: %Rrc (process error %Rrc)\n",
     874                                        VBoxServiceError("ControlExec: Could not report process start error! Error: %Rrc (process error %Rrc)\n",
    866875                                                         rc2, rc);
    867876                                }
     
    882891
    883892    VbglR3GuestCtrlDisconnect(pThread->uClientID);
    884     VBoxServiceVerbose(3, "Control: Thread of process \"%s\" (PID: %u) ended with rc=%Rrc\n",
     893    VBoxServiceVerbose(3, "ControlExec: Thread of process \"%s\" (PID: %u) ended with rc=%Rrc\n",
    885894                       pData->pszCmd, pData->uPID, rc);
    886895    return rc;
     
    920929            if (RT_FAILURE(rc))
    921930            {
    922                 VBoxServiceError("Control: RTThreadCreate failed, rc=%Rrc\n, pThread=%p\n",
     931                VBoxServiceError("ControlExec: RTThreadCreate failed, rc=%Rrc\n, pThread=%p\n",
    923932                                 rc, pThread);
    924933            }
     
    929938                if (pThread->fShutdown)
    930939                {
    931                     VBoxServiceError("Control: Thread for process \"%s\" failed to start!\n", pszCmd);
     940                    VBoxServiceError("ControlExec: Thread for process \"%s\" failed to start!\n", pszCmd);
    932941                    rc = VERR_GENERAL_FAILURE;
    933942                }
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