VirtualBox

Changeset 49570 in vbox


Ignore:
Timestamp:
Nov 20, 2013 9:13:04 AM (11 years ago)
Author:
vboxsync
Message:

Main/GuestProcessImpl.cpp: Don't use AssertReleaseMsg() in host callbacks, also check for stale guest processes in protocol v2, unified guestRc handling in GuestProcessTool::RunEx().

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r49504 r49570  
    519519 * a process B. Process B in turn then has a different guest PID.
    520520 *
     521 * Note: This also can happen when restoring from a saved state which
     522 *       had a guest process running.
     523 *
    521524 * @return  IPRT status code.
    522525 * @param   uPID                    PID to check.
     
    524527inline int GuestProcess::checkPID(uint32_t uPID)
    525528{
     529    int rc = VINF_SUCCESS;
     530
    526531    /* Was there a PID assigned yet? */
    527532    if (mData.mPID)
    528533    {
    529         /*
    530 
    531          */
    532         if (mSession->getProtocolVersion() < 2)
    533         {
    534             /* Simply ignore the stale requests. */
    535             return (mData.mPID == uPID)
    536                    ? VINF_SUCCESS : VERR_NOT_FOUND;
    537         }
    538 #ifndef DEBUG_andy
    539         /* This should never happen! */
    540         AssertReleaseMsg(mData.mPID == uPID, ("Unterminated guest process (guest PID %RU32) sent data to a newly started process (host PID %RU32)\n",
    541                                               uPID, mData.mPID));
    542 #endif
    543     }
    544 
    545     return VINF_SUCCESS;
     534        if (RT_UNLIKELY(mData.mPID != uPID))
     535        {
     536            LogFlowFunc(("Stale guest process (PID=%RU32) sent data to a newly started process (pProcesS=%p, PID=%RU32, status=%RU32)\n",
     537                         uPID, this, mData.mPID, mData.mStatus));
     538            rc = VERR_NOT_FOUND;
     539        }
     540    }
     541
     542    return rc;
    546543}
    547544
     
    865862
    866863/**
    867  * Called by IGuestSession right before this process gets 
    868  * removed from the public process list. 
     864 * Called by IGuestSession right before this process gets
     865 * removed from the public process list.
    869866 */
    870867int GuestProcess::onRemove(void)
     
    876873    int vrc = VINF_SUCCESS;
    877874
    878     /* 
     875    /*
    879876     * Note: The event source stuff holds references to this object,
    880877     *       so make sure that this is cleaned up *before* calling uninit().
     
    20602057    int vrc = pSession->processCreateExInteral(mStartupInfo, pProcess);
    20612058    if (RT_SUCCESS(vrc))
    2062         vrc = fAsync 
    2063             ? pProcess->startProcessAsync() 
     2059        vrc = fAsync
     2060            ? pProcess->startProcessAsync()
    20642061            : pProcess->startProcess(30 * 1000 /* 30s timeout */, pGuestRc);
    20652062
     
    21642161        /* Make sure the process runs until completion. */
    21652162        vrc = procTool.Wait(GUESTPROCESSTOOL_FLAG_NONE, &guestRc);
    2166 
    2167         Assert(RT_SUCCESS(guestRc));
    2168         guestRc = procTool.TerminatedOk(NULL /* Exit code */);
    2169         if (RT_FAILURE(guestRc))
    2170             vrc = VERR_GSTCTL_GUEST_ERROR;                       
    2171         if (pGuestRc)
    2172             *pGuestRc = guestRc;
    2173     }
    2174     else if (vrc == VERR_GSTCTL_GUEST_ERROR)
    2175     {
    2176         if (pGuestRc)
    2177             *pGuestRc = guestRc;
    2178     }
     2163        if (RT_SUCCESS(vrc))
     2164        {
     2165            guestRc = procTool.TerminatedOk(NULL /* Exit code */);
     2166            if (RT_FAILURE(guestRc))
     2167                vrc = VERR_GSTCTL_GUEST_ERROR;
     2168        }
     2169    }
     2170
     2171    if (pGuestRc)
     2172        *pGuestRc = guestRc;
    21792173
    21802174    LogFlowFunc(("Returned rc=%Rrc, guestRc=%Rrc\n", vrc, guestRc));
     
    23222316
    23232317            default:
    2324                 AssertReleaseMsgFailed(("Unhandled process wait result %RU32\n", waitRes));
     2318                AssertMsgFailed(("Unhandled process wait result %RU32\n", waitRes));
    23252319                break;
    23262320        }
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r49504 r49570  
    283283
    284284#ifdef VBOX_WITH_GUEST_CONTROL
    285     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 
     285    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    286286
    287287    LogFlowThisFunc(("Closing directories (%zu total)\n",
     
    321321    mData.mProcesses.clear();
    322322
    323     AssertMsg(mData.mNumObjects == 0, 
     323    AssertMsg(mData.mNumObjects == 0,
    324324              ("mNumObjects=%RU32 when it should be 0\n", mData.mNumObjects));
    325325
     
    731731                vrc = VERR_INVALID_PARAMETER;
    732732        }
    733        
     733
    734734        if (uMode)
    735735        {
     
    808808            LogFlowFunc(("Removing directory \"%s\" (Session: %RU32) (now total %zu processes, %ld objects)\n",
    809809                         Utf8Str(strName).c_str(), mData.mSession.mID, mData.mDirectories.size() - 1, mData.mNumObjects - 1));
    810  
     810
    811811            rc = pDirectory->onRemove();
    812812            mData.mDirectories.erase(itDirs);
     
    11941194    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    11951195
    1196     int rc = VERR_NOT_FOUND;   
     1196    int rc = VERR_NOT_FOUND;
    11971197
    11981198    SessionFiles::iterator itFiles = mData.mFiles.begin();
     
    12211221            fireGuestFileRegisteredEvent(mEventSource, this, pCurFile,
    12221222                                         false /* Unregistered */);
    1223             pCurFile.setNull();           
     1223            pCurFile.setNull();
    12241224            break;
    12251225        }
     
    12291229
    12301230    LogFlowFuncLeaveRC(rc);
    1231     return rc;   
     1231    return rc;
    12321232}
    12331233
     
    14261426    }
    14271427
    1428     LogFlowFuncLeaveRC(vrc);
     1428    LogFlowThisFunc(("Returning rc=%Rrc, guestRc=%Rrc\n",
     1429                     vrc, guestRc));
    14291430    return vrc;
    14301431}
     
    15151516
    15161517/**
    1517  * Called by IGuest right before this session gets removed from 
    1518  * the public session list. 
     1518 * Called by IGuest right before this session gets removed from
     1519 * the public session list.
    15191520 */
    15201521int GuestSession::onRemove(void)
     
    15261527    int vrc = VINF_SUCCESS;
    15271528
    1528     /* 
     1529    /*
    15291530     * Note: The event source stuff holds references to this object,
    15301531     *       so make sure that this is cleaned up *before* calling uninit.
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