VirtualBox

Ignore:
Timestamp:
Jan 24, 2011 4:16:38 PM (14 years ago)
Author:
vboxsync
Message:

VBoxService/ControlExec: Fix for high CPU loads during writable events of started processes.

File:
1 edited

Legend:

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

    r35674 r35690  
    6464    {
    6565        int rc2 = RTPollSetRemove(hPollSet, VBOXSERVICECTRLPIPEID_STDIN_WRITABLE);
    66         AssertRC(rc2);
     66        /* Don't assert if writable handle is not in poll set anymore. */
     67        if (   RT_FAILURE(rc2)
     68            && rc2 != VERR_POLL_HANDLE_ID_NOT_FOUND)
     69                {
     70            AssertRC(rc2);
     71                }
    6772
    6873        rc2 = RTPipeClose(*phStdInW);
     
    209214            rc = VBoxServiceControlExecProcHandleStdInErrorEvent(hPollSet, fPollEvt, phStdInW, pStdInBuf);
    210215        }
     216        else if (!*pcbWritten)
     217        {
     218            /* Nothing else left to write now? Remove the writable event from the poll set
     219             * to not trigger too high CPU loads. */
     220            rc = RTPollSetRemove(hPollSet, VBOXSERVICECTRLPIPEID_STDIN_WRITABLE);
     221            AssertRC(rc);
     222        }
    211223    }
    212224    else
     
    388400        if (RT_SUCCESS(rc2))
    389401        {
    390 #ifdef DEBUG
    391402            VBoxServiceVerbose(4, "ControlExec: RTPollNoResume idPollHnd=%u\n", idPollHnd);
    392 #endif
    393403            switch (idPollHnd)
    394404            {
     
    402412                    uint8_t abBuf[8];
    403413                    size_t cbIgnore;
    404                     RTPipeRead(pData->stdIn.hNotificationPipeR, abBuf, sizeof(abBuf), &cbIgnore);
     414                    rc = RTPipeRead(pData->stdIn.hNotificationPipeR, abBuf, sizeof(abBuf), &cbIgnore);
     415                    if (RT_SUCCESS(rc))
     416                    {
     417                        /*
     418                         * When the writable handle previously was removed from the poll set we need to add
     419                         * it here again so that writable events from the started procecss get handled correctly.
     420                         */
     421                        RTHANDLE hWritableIgnored;
     422                        rc = RTPollSetQueryHandle(hPollSet, VBOXSERVICECTRLPIPEID_STDIN_WRITABLE, &hWritableIgnored);
     423                        if (rc == VERR_POLL_HANDLE_ID_NOT_FOUND)
     424                        {
     425                            rc = RTPollSetAddPipe(hPollSet, pData->pipeStdInW, RTPOLL_EVT_WRITE, VBOXSERVICECTRLPIPEID_STDIN_WRITABLE);
     426                            AssertRC(rc);
     427                            break;
     428                        }
     429                        AssertRC(rc);
     430                    }
    405431                }
    406432                /* Fall through. */
     
    632658static int VBoxServiceControlExecSetupPipe(int fd, PRTHANDLE ph, PRTHANDLE *pph, PRTPIPE phPipe)
    633659{
    634     AssertPtr(ph);
    635     AssertPtr(pph);
    636     AssertPtr(phPipe);
     660    AssertPtrReturn(ph, VERR_INVALID_PARAMETER);
     661    AssertPtrReturn(pph, VERR_INVALID_PARAMETER);
     662    AssertPtrReturn(phPipe, VERR_INVALID_PARAMETER);
    637663
    638664    ph->enmType = RTHANDLETYPE_PIPE;
     
    677703static int VBoxServiceControlExecInitPipeBuffer(PVBOXSERVICECTRLEXECPIPEBUF pBuf, bool fNeedNotificationPipe)
    678704{
    679     AssertPtr(pBuf);
     705    AssertPtrReturn(pBuf, VERR_INVALID_PARAMETER);
    680706
    681707    /** @todo Add allocation size as function parameter! */
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