VirtualBox

Changeset 47481 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 30, 2013 7:11:43 PM (11 years ago)
Author:
vboxsync
Message:

VBoxService/GuestCtrl: Don't hang on PID reuse.

File:
1 edited

Legend:

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

    r47476 r47481  
    13661366 *
    13671367 * @return  IPRT status code.
    1368  * @param   pThread        Thread to assign PID to.
     1368 * @param   pProcess       Process to assign PID to.
    13691369 * @param   uPID           PID to assign to the specified guest control execution thread.
    13701370 */
    1371 int gstcntlProcessAssignPID(PVBOXSERVICECTRLPROCESS pThread, uint32_t uPID)
    1372 {
    1373     AssertPtrReturn(pThread, VERR_INVALID_POINTER);
     1371int gstcntlProcessAssignPID(PVBOXSERVICECTRLPROCESS pProcess, uint32_t uPID)
     1372{
     1373    AssertPtrReturn(pProcess, VERR_INVALID_POINTER);
    13741374    AssertReturn(uPID, VERR_INVALID_PARAMETER);
    13751375
    1376     AssertPtr(pThread->pSession);
    1377     int rc = RTCritSectEnter(&pThread->pSession->CritSect);
     1376    AssertPtr(pProcess->pSession);
     1377    int rc = RTCritSectEnter(&pProcess->pSession->CritSect);
    13781378    if (RT_SUCCESS(rc))
    13791379    {
    13801380        /* Search old threads using the desired PID and shut them down completely -- it's
    13811381         * not used anymore. */
    1382         PVBOXSERVICECTRLPROCESS pThreadCur;
    1383         bool fTryAgain = false;
     1382        PVBOXSERVICECTRLPROCESS pProcessCur;
     1383        bool fTryAgain;
    13841384        do
    13851385        {
    1386             RTListForEach(&pThread->pSession->lstProcessesActive, pThreadCur, VBOXSERVICECTRLPROCESS, Node)
    1387             {
    1388                 if (pThreadCur->uPID == uPID)
     1386            fTryAgain = false;
     1387            RTListForEach(&pProcess->pSession->lstProcessesActive, pProcessCur, VBOXSERVICECTRLPROCESS, Node)
     1388            {
     1389                if (pProcessCur->uPID == uPID)
    13891390                {
    1390                     Assert(pThreadCur != pThread); /* can't happen */
     1391                    Assert(pProcessCur != pProcess); /* can't happen */
    13911392                    uint32_t uTriedPID = uPID;
    13921393                    uPID += 391939;
    1393                     VBoxServiceVerbose(2, "PID %RU32 was used before, trying again with %u ...\n",
    1394                                        uTriedPID, uPID);
     1394                    VBoxServiceVerbose(2, "PID %RU32 was used before (process %p), trying again with %RU32 ...\n",
     1395                                       uTriedPID, pProcessCur, uPID);
    13951396                    fTryAgain = true;
    13961397                    break;
     
    14001401
    14011402        /* Assign PID to current thread. */
    1402         pThread->uPID = uPID;
    1403 
    1404         rc = RTCritSectLeave(&pThread->pSession->CritSect);
     1403        pProcess->uPID = uPID;
     1404
     1405        rc = RTCritSectLeave(&pProcess->pSession->CritSect);
    14051406        AssertRC(rc);
    14061407    }
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