VirtualBox

Changeset 38587 in vbox


Ignore:
Timestamp:
Aug 31, 2011 3:09:45 PM (13 years ago)
Author:
vboxsync
Message:

VBoxService/GuestCtrl: Update.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
6 edited

Legend:

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

    r38157 r38587  
    252252}
    253253
     254
    254255void VBoxServiceControlThreadSignalShutdown(const PVBOXSERVICECTRLTHREAD pThread)
    255256{
     
    263264    AssertPtrReturn(pThread, VERR_INVALID_POINTER);
    264265    int rc = VINF_SUCCESS;
    265     if (pThread->Thread != NIL_RTTHREAD)
     266    if (   pThread->Thread != NIL_RTTHREAD
     267        && !pThread->fShutdown) /* Only shutdown threads which aren't yet. */
    266268    {
    267269        /* Wait a bit ... */
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp

    r38493 r38587  
    14111411                VBoxServiceError("ControlExec: [PID %u]: Failed to retrieve output, CID=%u, uHandle=%u, rc=%Rrc\n",
    14121412                                 uPID, uContextID, uHandleID, rc);
    1413 
    14141413            /* Note: Since the context ID is unique the request *has* to be completed here,
    14151414             *       regardless whether we got data or not! Otherwise the progress object
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExecThread.cpp

    r38493 r38587  
    380380            if (RT_SUCCESS(rc))
    381381            {
    382                 uint32_t cbRead = cbSize;
     382                uint32_t cbRead = cbSize; /* Read as much as possible. */
    383383                rc = VBoxServicePipeBufRead(pPipeBuf, pBuf, cbSize, &cbRead);
    384384                if (RT_SUCCESS(rc))
    385385                {
    386 #if 0
    387                     if (!cbRead)
    388                         AssertReleaseMsg(fEnabled == VBoxServicePipeBufIsEnabled(pPipeBuf),
     386                    if (   !cbRead
     387                        && fEnabled)
     388                    {
     389                        AssertReleaseMsg(!VBoxServicePipeBufIsEnabled(pPipeBuf),
    389390                                         ("[PID %u]: Waited (%ums) for active pipe buffer %u (%u size, %u bytes left), but nothing read!\n",
    390391                                         uPID, uTimeout, pPipeBuf->uPipeId, pPipeBuf->cbSize, pPipeBuf->cbSize - pPipeBuf->cbOffset));
    391 #endif
     392                    }
    392393                    if (pcbRead)
    393394                        *pcbRead = cbRead;
     
    409410
    410411
     412int VBoxServiceControlExecThreadRemove(uint32_t uPID)
     413{
     414    int rc = RTCritSectEnter(&g_GuestControlThreadsCritSect);
     415    if (RT_SUCCESS(rc))
     416    {
     417        PVBOXSERVICECTRLTHREAD pThread = vboxServiceControlExecThreadGetByPID(uPID);
     418        if (pThread)
     419        {
     420            Assert(pThread->fStarted != pThread->fStopped);
     421            if (pThread->fStopped) /* Only shut down stopped threads. */
     422            {
     423                VBoxServiceVerbose(4, "ControlExec: [PID %u]: Removing thread ... \n",
     424                                   uPID);
     425
     426                rc = VBoxServiceControlExecThreadShutdown(pThread);
     427
     428                RTListNodeRemove(&pThread->Node);
     429                RTMemFree(pThread);
     430            }
     431        }
     432        else
     433            rc = VERR_NOT_FOUND;
     434
     435        int rc2 = RTCritSectLeave(&g_GuestControlThreadsCritSect);
     436        if (RT_SUCCESS(rc))
     437            rc = rc2;
     438    }
     439
     440    return rc;
     441}
     442
     443/* Does not do locking, must be done by the caller! */
    411444int VBoxServiceControlExecThreadShutdown(const PVBOXSERVICECTRLTHREAD pThread)
    412445{
     
    437470int VBoxServiceControlExecThreadStartAllowed(bool *pbAllowed)
    438471{
     472    AssertPtrReturn(pbAllowed, VERR_INVALID_POINTER);
     473
    439474    int rc = RTCritSectEnter(&g_GuestControlThreadsCritSect);
    440475    if (RT_SUCCESS(rc))
     
    445480         */
    446481        bool fLimitReached = false;
    447         if (g_GuestControlProcsMaxKept) /* If we allow unlimited processes, take a shortcut. */
     482        if (g_GuestControlProcsMaxKept) /* If we allow unlimited processes (=0), take a shortcut. */
    448483        {
    449484            /** @todo Put running/stopped (+ memory alloc) stats into global struct! */
     
    471506            if (iProcsLeft < 0)
    472507            {
    473                 VBoxServiceVerbose(3, "ControlExec: Maximum running guest processes reached\n");
     508                VBoxServiceVerbose(3, "ControlExec: Maximum running guest processes reached (%u)\n",
     509                                   g_GuestControlProcsMaxKept);
    474510                fLimitReached = true;
    475511            }
     
    490526                        if (RT_FAILURE(rc2))
    491527                        {
    492                             VBoxServiceError("ControlExec: Unable to shut down thread due to policy, rc=%Rrc", rc2);
     528                            VBoxServiceError("ControlExec: Unable to shut down thread due to policy, rc=%Rrc\n", rc2);
    493529                            if (RT_SUCCESS(rc))
    494530                                rc = rc2;
     
    500536                        pNode = pNext;
    501537
     538                        Assert(uProcsToKill);
    502539                        uProcsToKill--;
    503540                        if (!uProcsToKill)
    504541                            break;
    505 
    506542                    }
    507543                }
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExecThread.h

    r38180 r38587  
    3131int VBoxServiceControlExecThreadGetOutput(uint32_t uPID, uint32_t uHandleId, uint32_t uTimeout,
    3232                                          uint8_t *pBuf, uint32_t cbSize, uint32_t *pcbRead);
     33int VBoxServiceControlExecThreadRemove(uint32_t uPID);
    3334int VBoxServiceControlExecThreadSetInput(uint32_t uPID, bool fPendingClose, uint8_t *pBuf,
    3435                                         uint32_t cbSize, uint32_t *pcbWritten);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r38180 r38587  
    158158    RTPIPE      hNotificationPipeR;
    159159    /** The event semaphore for getting notified whether something
    160      *  has changed, e.g. written or read from this buffer. */
     160     *  has changed, e.g. written to this buffer or enabled/disabled it. */
    161161    RTSEMEVENT  hEventSem;
    162162} VBOXSERVICECTRLEXECPIPEBUF;
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServicePipeBuf.cpp

    r38493 r38587  
    112112
    113113#ifdef DEBUG_andy
    114             VBoxServiceVerbose(4, "Pipe [%u %u 0x%p %s] read pcbToRead=%u, cbSize=%u, cbAlloc=%u, cbOff=%u\n",
     114            VBoxServiceVerbose(4, "Pipe [%u %u 0x%p %s] read cbToRead=%u, cbSize=%u, cbAlloc=%u, cbOff=%u\n",
    115115                               pBuf->uPID, pBuf->uPipeId, pBuf, pBuf->fEnabled ? "EN" : "DIS", cbToRead, pBuf->cbSize, pBuf->cbAllocated, pBuf->cbOffset);
    116116#endif
    117             if (pBuf->hEventSem != NIL_RTSEMEVENT)
    118             {
    119                 rc = RTSemEventSignal(pBuf->hEventSem);
    120                 AssertRC(rc);
    121             }
     117            /* Don't signal event semaphore here -- we only read out something from
     118             * this pipe buffer. */
    122119
    123120            *pcbToRead = cbToRead;
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