VirtualBox

Changeset 49504 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 15, 2013 1:19:45 PM (11 years ago)
Author:
vboxsync
Message:

Main/GuestCtrl: Reference counting bugfixes, handle more directoryCreate errors.

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

Legend:

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

    r49392 r49504  
    347347    int rc = VERR_NOT_FOUND;
    348348
    349     LogFlowFunc(("Closing session (ID=%RU32) ...\n", pSession->getId()));
     349    LogFlowThisFunc(("Removing session (ID=%RU32) ...\n", pSession->getId()));
    350350
    351351    GuestSessions::iterator itSessions = mData.mGuestSessions.begin();
     
    354354        if (pSession == itSessions->second)
    355355        {
     356#ifdef DEBUG_andy
     357            ULONG cRefs = pSession->AddRef();
     358            Assert(cRefs >= 2);
     359            LogFlowThisFunc(("pCurSession=%p, cRefs=%RU32\n", pSession, cRefs - 2));
     360            pSession->Release();
     361#endif
    356362            /* Make sure to consume the pointer before the one of the
    357363             * iterator gets released. */
    358364            ComObjPtr<GuestSession> pCurSession = pSession;
    359365
    360             LogFlowFunc(("Removing session (pSession=%p, ID=%RU32) (now total %ld sessions)\n",
    361                          pSession, pSession->getId(), mData.mGuestSessions.size() - 1));
    362 
    363             itSessions->second->Release();
    364 
     366            LogFlowThisFunc(("Removing session (pSession=%p, ID=%RU32) (now total %ld sessions)\n",
     367                             pSession, pSession->getId(), mData.mGuestSessions.size() - 1));
     368
     369            rc = pSession->onRemove();
    365370            mData.mGuestSessions.erase(itSessions);
    366371
     
    369374            fireGuestSessionRegisteredEvent(mEventSource, pCurSession,
    370375                                            false /* Unregistered */);
    371             rc = VINF_SUCCESS;
     376            pCurSession.setNull();     
    372377            break;
    373378        }
  • trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp

    r49349 r49504  
    133133void GuestDirectory::uninit(void)
    134134{
    135     LogFlowThisFunc(("\n"));
     135    LogFlowThisFuncEnter();
    136136
    137137    /* Enclose the state transition Ready->InUninit->NotReady. */
     
    246246
    247247    return strError;
     248}
     249
     250/**
     251 * Called by IGuestSession right before this directory gets
     252 * removed from the public directory list.
     253 */
     254int GuestDirectory::onRemove(void)
     255{
     256    LogFlowThisFuncEnter();
     257
     258    int vrc = VINF_SUCCESS;
     259         
     260    LogFlowFuncLeaveRC(vrc);
     261    return vrc;
    248262}
    249263
  • trunk/src/VBox/Main/src-client/GuestFileImpl.cpp

    r49440 r49504  
    1 
    21/* $Id$ */
    32/** @file
     
    7978                int rc2 = mFile->signalWaitEvent(aType, aEvent);
    8079#ifdef DEBUG_andy
    81                 LogFlowFunc(("Signalling events of type=%ld, file=%p resulted in rc=%Rrc\n",
     80                LogFlowFunc(("Signalling events of type=%RU32, file=%p resulted in rc=%Rrc\n",
    8281                             aType, mFile, rc2));
    8382#endif
     
    8685
    8786            default:
    88                 AssertMsgFailed(("Unhandled event %ld\n", aType));
     87                AssertMsgFailed(("Unhandled event %RU32\n", aType));
    8988                break;
    9089        }
     
    225224void GuestFile::uninit(void)
    226225{
    227     LogFlowThisFuncEnter();
    228 
    229226    /* Enclose the state transition Ready->InUninit->NotReady. */
    230227    AutoUninitSpan autoUninitSpan(this);
     
    232229        return;
    233230
     231    LogFlowThisFuncEnter();
     232
    234233#ifdef VBOX_WITH_GUEST_CONTROL
    235234    baseUninit();
    236 
    237     if (!mEventSource.isNull())
    238     {
    239         mEventSource->UnregisterListener(mLocalListener);
    240 
    241         mLocalListener.setNull();
    242         unconst(mEventSource).setNull();
    243     }
    244235#endif
    245 
    246236    LogFlowThisFuncLeave();
    247237}
     
    707697
    708698    int vrc = setFileStatus(FileStatus_Down, VINF_SUCCESS);
     699
     700    LogFlowFuncLeaveRC(vrc);
     701    return vrc;
     702}
     703
     704/**
     705 * Called by IGuestSession right before this file gets removed
     706 * from the public file list.
     707 */
     708int GuestFile::onRemove(void)
     709{
     710    LogFlowThisFuncEnter();
     711
     712    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     713
     714    int vrc = VINF_SUCCESS;
     715
     716    /*
     717     * Note: The event source stuff holds references to this object,
     718     *       so make sure that this is cleaned up *before* calling uninit().
     719     */
     720    if (!mEventSource.isNull())
     721    {
     722        mEventSource->UnregisterListener(mLocalListener);
     723
     724        mLocalListener.setNull();
     725        unconst(mEventSource).setNull();
     726    }
    709727
    710728    LogFlowFuncLeaveRC(vrc);
     
    944962    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    945963
    946     LogFlowThisFunc(("oldStatus=%ld, newStatus=%ld, fileRc=%Rrc\n",
     964    LogFlowThisFunc(("oldStatus=%RU32, newStatus=%RU32, fileRc=%Rrc\n",
    947965                     mData.mStatus, fileStatus, fileRc));
    948966
  • trunk/src/VBox/Main/src-client/GuestFsObjInfoImpl.cpp

    r42897 r49504  
    1 
    21/* $Id$ */
    32/** @file
    4  * VirtualBox Main - XXX.
     3 * VirtualBox Main - Guest file system object information handling.
    54 */
    65
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r49440 r49504  
    1 
    21/* $Id$ */
    32/** @file
     
    118117                int rc2 = mProcess->signalWaitEvent(aType, aEvent);
    119118#ifdef DEBUG
    120                 LogFlowThisFunc(("Signalling events of type=%ld, pProcess=%p resulted in rc=%Rrc\n",
     119                LogFlowThisFunc(("Signalling events of type=%RU32, pProcess=%p resulted in rc=%Rrc\n",
    121120                                 aType, &mProcess, rc2));
    122121#endif
     
    125124
    126125            default:
    127                 AssertMsgFailed(("Unhandled event %ld\n", aType));
     126                AssertMsgFailed(("Unhandled event %RU32\n", aType));
    128127                break;
    129128        }
     
    256255/**
    257256 * Uninitializes the instance.
    258  * Called from FinalRelease().
     257 * Called from FinalRelease() or IGuestSession::uninit().
    259258 */
    260259void GuestProcess::uninit(void)
    261260{
    262     LogFlowThisFuncEnter();
    263 
    264261    /* Enclose the state transition Ready->InUninit->NotReady. */
    265262    AutoUninitSpan autoUninitSpan(this);
     
    267264        return;
    268265
     266#ifdef VBOX_WITH_GUEST_CONTROL
    269267    LogFlowThisFunc(("mCmd=%s, PID=%RU32\n",
    270268                     mData.mProcess.mCommand.c_str(), mData.mPID));
     
    276274     *       case of failure. */
    277275
    278 #ifdef VBOX_WITH_GUEST_CONTROL
    279276    baseUninit();
    280 
    281     if (!mEventSource.isNull())
    282     {
    283         mEventSource->UnregisterListener(mLocalListener);
    284 
    285         mLocalListener.setNull();
    286         unconst(mEventSource).setNull();
    287     }
    288 #endif
    289277
    290278    LogFlowThisFunc(("Returning rc=%Rrc, guestRc=%Rrc\n",
    291279                     vrc, guestRc));
     280#endif
    292281}
    293282
     
    826815        }
    827816
    828         LogFlowThisFunc(("Got rc=%Rrc, procSts=%ld, procRc=%Rrc\n",
     817        LogFlowThisFunc(("Got rc=%Rrc, procSts=%RU32, procRc=%Rrc\n",
    829818                         vrc, procStatus, procRc));
    830819
     
    875864}
    876865
     866/**
     867 * Called by IGuestSession right before this process gets
     868 * removed from the public process list.
     869 */
     870int GuestProcess::onRemove(void)
     871{
     872    LogFlowThisFuncEnter();
     873
     874    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     875
     876    int vrc = VINF_SUCCESS;
     877
     878    /*
     879     * Note: The event source stuff holds references to this object,
     880     *       so make sure that this is cleaned up *before* calling uninit().
     881     */
     882    if (!mEventSource.isNull())
     883    {
     884        mEventSource->UnregisterListener(mLocalListener);
     885
     886        mLocalListener.setNull();
     887        unconst(mEventSource).setNull();
     888    }
     889
     890    LogFlowFuncLeaveRC(vrc);
     891    return vrc;
     892}
     893
    877894int GuestProcess::readData(uint32_t uHandle, uint32_t uSize, uint32_t uTimeoutMS,
    878895                           void *pvData, size_t cbData, uint32_t *pcbRead, int *pGuestRc)
     
    962979    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    963980
    964     LogFlowThisFunc(("oldStatus=%ld, newStatus=%ld, procRc=%Rrc\n",
     981    LogFlowThisFunc(("oldStatus=%RU32, newStatus=%RU32, procRc=%Rrc\n",
    965982                     mData.mStatus, procStatus, procRc));
    966983
     
    12361253    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    12371254
     1255    int vrc = VINF_SUCCESS;
     1256
    12381257    if (mData.mStatus != ProcessStatus_Started)
    12391258    {
    1240         LogFlowThisFunc(("Process not started state (state is %ld), skipping termination\n",
     1259        LogFlowThisFunc(("Process not in started state (state is %RU32), skipping termination\n",
    12411260                         mData.mStatus));
    1242         return VINF_SUCCESS; /* Nothing to do (anymore). */
    1243     }
    1244 
    1245     int vrc = VINF_SUCCESS;
    1246 
    1247     AssertPtr(mSession);
    1248     /* Note: VBox < 4.3 (aka protocol version 1) does not
    1249      *       support this, so just skip. */
    1250     if (mSession->getProtocolVersion() < 2)
    1251         vrc = VERR_NOT_SUPPORTED;
    1252 
    1253     if (RT_SUCCESS(vrc))
    1254     {
    1255         GuestWaitEvent *pEvent = NULL;
    1256         GuestEventTypes eventTypes;
    1257         try
    1258         {
    1259             eventTypes.push_back(VBoxEventType_OnGuestProcessStateChanged);
    1260 
    1261             vrc = registerWaitEvent(eventTypes, &pEvent);
    1262         }
    1263         catch (std::bad_alloc)
    1264         {
    1265             vrc = VERR_NO_MEMORY;
    1266         }
    1267 
    1268         if (RT_FAILURE(vrc))
    1269             return vrc;
    1270 
    1271         VBOXHGCMSVCPARM paParms[4];
    1272         int i = 0;
    1273         paParms[i++].setUInt32(pEvent->ContextID());
    1274         paParms[i++].setUInt32(mData.mPID);
    1275 
    1276         alock.release(); /* Drop the write lock before sending. */
    1277 
    1278         vrc = sendCommand(HOST_EXEC_TERMINATE, i, paParms);
     1261    }
     1262    else
     1263    {
     1264        AssertPtr(mSession);
     1265        /* Note: VBox < 4.3 (aka protocol version 1) does not
     1266         *       support this, so just skip. */
     1267        if (mSession->getProtocolVersion() < 2)
     1268            vrc = VERR_NOT_SUPPORTED;
     1269
    12791270        if (RT_SUCCESS(vrc))
    1280             vrc = waitForStatusChange(pEvent, uTimeoutMS,
    1281                                       NULL /* ProcessStatus */, pGuestRc);
    1282         unregisterWaitEvent(pEvent);
     1271        {
     1272            GuestWaitEvent *pEvent = NULL;
     1273            GuestEventTypes eventTypes;
     1274            try
     1275            {
     1276                eventTypes.push_back(VBoxEventType_OnGuestProcessStateChanged);
     1277
     1278                vrc = registerWaitEvent(eventTypes, &pEvent);
     1279            }
     1280            catch (std::bad_alloc)
     1281            {
     1282                vrc = VERR_NO_MEMORY;
     1283            }
     1284
     1285            if (RT_FAILURE(vrc))
     1286                return vrc;
     1287
     1288            VBOXHGCMSVCPARM paParms[4];
     1289            int i = 0;
     1290            paParms[i++].setUInt32(pEvent->ContextID());
     1291            paParms[i++].setUInt32(mData.mPID);
     1292
     1293            alock.release(); /* Drop the write lock before sending. */
     1294
     1295            vrc = sendCommand(HOST_EXEC_TERMINATE, i, paParms);
     1296            if (RT_SUCCESS(vrc))
     1297                vrc = waitForStatusChange(pEvent, uTimeoutMS,
     1298                                          NULL /* ProcessStatus */, pGuestRc);
     1299            unregisterWaitEvent(pEvent);
     1300        }
    12831301    }
    12841302
     
    13371355
    13381356                default:
    1339                     AssertMsgFailed(("Unhandled old status %ld before new status 'started'\n",
     1357                    AssertMsgFailed(("Unhandled old status %RU32 before new status 'started'\n",
    13401358                                     oldStatus));
    13411359                    waitResult = ProcessWaitResult_Start;
     
    13811399
    13821400#ifdef DEBUG
    1383     LogFlowFunc(("oldStatus=%ld, newStatus=%ld, fWaitFlags=0x%x, waitResult=%ld\n",
     1401    LogFlowFunc(("oldStatus=%RU32, newStatus=%RU32, fWaitFlags=0x%x, waitResult=%RU32\n",
    13841402                 oldStatus, newStatus, fWaitFlags, waitResult));
    13851403#endif
     
    14781496                                             mData.mProcess.mFlags, mSession->getProtocolVersion());
    14791497#ifdef DEBUG
    1480             LogFlowThisFunc(("Got new status change: fWaitFlags=0x%x, newStatus=%ld, waitResult=%ld\n",
     1498            LogFlowThisFunc(("Got new status change: fWaitFlags=0x%x, newStatus=%RU32, waitResult=%RU32\n",
    14811499                             fWaitFlags, newStatus, waitResult));
    14821500#endif
     
    14921510    unregisterWaitEvent(pEvent);
    14931511
    1494     LogFlowThisFunc(("Returned waitResult=%ld, newStatus=%ld, rc=%Rrc\n",
     1512    LogFlowThisFunc(("Returned waitResult=%RU32, newStatus=%RU32, rc=%Rrc\n",
    14951513                     waitResult, newStatus, vrc));
    14961514    return vrc;
     
    18601878    }
    18611879
    1862     /* Remove the process from our internal session list. Only an API client
    1863      * now may hold references to it. */
     1880    /* Remove process from guest session list. Now only API clients
     1881     * still can hold references to it. */
    18641882    AssertPtr(mSession);
    18651883    mSession->processRemoveFromList(this);
     
    20162034
    20172035GuestProcessTool::GuestProcessTool(void)
    2018     : pSession(NULL)
     2036    : pSession(NULL),
     2037      pProcess(NULL)
    20192038{
    20202039}
     
    20412060    int vrc = pSession->processCreateExInteral(mStartupInfo, pProcess);
    20422061    if (RT_SUCCESS(vrc))
    2043         vrc = fAsync ? pProcess->startProcessAsync() : pProcess->startProcess(30 * 1000 /* 30s timeout */,
    2044                                                                               pGuestRc);
     2062        vrc = fAsync
     2063            ? pProcess->startProcessAsync()
     2064            : pProcess->startProcess(30 * 1000 /* 30s timeout */, pGuestRc);
    20452065
    20462066    if (   RT_SUCCESS(vrc)
     
    20912111    Assert(SUCCEEDED(hr));
    20922112
    2093     if (   procStatus != ProcessStatus_Started
    2094         && procStatus != ProcessStatus_Paused
    2095         && procStatus != ProcessStatus_Terminating)
    2096     {
    2097         return false;
    2098     }
    2099 
    2100     return true;
     2113    if (   procStatus == ProcessStatus_Started
     2114        || procStatus == ProcessStatus_Paused
     2115        || procStatus == ProcessStatus_Terminating)
     2116    {
     2117        return true;
     2118    }
     2119
     2120    return false;
    21012121}
    21022122
     
    21472167        Assert(RT_SUCCESS(guestRc));
    21482168        guestRc = procTool.TerminatedOk(NULL /* Exit code */);
     2169        if (RT_FAILURE(guestRc))
     2170            vrc = VERR_GSTCTL_GUEST_ERROR;                       
    21492171        if (pGuestRc)
    21502172            *pGuestRc = guestRc;
     
    23002322
    23012323            default:
    2302                 AssertReleaseMsgFailed(("Unhandled process wait result %ld\n", waitRes));
     2324                AssertReleaseMsgFailed(("Unhandled process wait result %RU32\n", waitRes));
    23032325                break;
    23042326        }
     
    23682390#undef GET_REMAINING_TIME
    23692391
    2370     LogFlowThisFunc(("Loop ended with rc=%Rrc, guestRc=%Rrc, waitRes=%ld\n",
     2392    if (RT_FAILURE(guestRc))
     2393        vrc = VERR_GSTCTL_GUEST_ERROR;
     2394
     2395    LogFlowThisFunc(("Loop ended with rc=%Rrc, guestRc=%Rrc, waitRes=%RU32\n",
    23712396                     vrc, guestRc, waitRes));
    23722397    if (pGuestRc)
     
    23852410    {
    23862411        rc = pProcess->terminateProcess(uTimeoutMS, pGuestRc);
    2387 
    2388         Assert(pSession);
    2389         int rc2 = pSession->processRemoveFromList(pProcess);
    2390         AssertRC(rc2);
    2391 
    23922412        pProcess.setNull();
    23932413    }
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r49389 r49504  
    1 
    21/* $Id$ */
    32/** @file
     
    116115                int rc2 = mSession->signalWaitEvent(aType, aEvent);
    117116#ifdef DEBUG_andy
    118                 LogFlowFunc(("Signalling events of type=%ld, session=%p resulted in rc=%Rrc\n",
     117                LogFlowFunc(("Signalling events of type=%RU32, session=%p resulted in rc=%Rrc\n",
    119118                             aType, mSession, rc2));
    120119#endif
     
    123122
    124123            default:
    125                 AssertMsgFailed(("Unhandled event %ld\n", aType));
     124                AssertMsgFailed(("Unhandled event %RU32\n", aType));
    126125                break;
    127126        }
     
    274273void GuestSession::uninit(void)
    275274{
    276     LogFlowThisFuncEnter();
    277 
    278275    /* Enclose the state transition Ready->InUninit->NotReady. */
    279276    AutoUninitSpan autoUninitSpan(this);
     
    281278        return;
    282279
     280    LogFlowThisFuncEnter();
     281
    283282    int rc = VINF_SUCCESS;
    284283
    285284#ifdef VBOX_WITH_GUEST_CONTROL
    286     LogFlowThisFunc(("Closing directories (%RU64 total)\n",
     285    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     286
     287    LogFlowThisFunc(("Closing directories (%zu total)\n",
    287288                     mData.mDirectories.size()));
    288289    for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
    289290         itDirs != mData.mDirectories.end(); ++itDirs)
    290291    {
    291         itDirs->second->Release();
     292        Assert(mData.mNumObjects);
     293        mData.mNumObjects--;
     294        itDirs->second->onRemove();
     295        itDirs->second->uninit();
    292296    }
    293297    mData.mDirectories.clear();
    294298
    295     LogFlowThisFunc(("Closing files (%RU64 total)\n",
     299    LogFlowThisFunc(("Closing files (%zu total)\n",
    296300                     mData.mFiles.size()));
    297301    for (SessionFiles::iterator itFiles = mData.mFiles.begin();
    298302         itFiles != mData.mFiles.end(); ++itFiles)
    299303    {
    300         itFiles->second->Release();
     304        Assert(mData.mNumObjects);
     305        mData.mNumObjects--;
     306        itFiles->second->onRemove();
     307        itFiles->second->uninit();
    301308    }
    302309    mData.mFiles.clear();
    303310
    304     LogFlowThisFunc(("Closing processes (%RU64 total)\n",
     311    LogFlowThisFunc(("Closing processes (%zu total)\n",
    305312                     mData.mProcesses.size()));
    306313    for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
    307314         itProcs != mData.mProcesses.end(); ++itProcs)
    308315    {
    309         itProcs->second->Release();
     316        Assert(mData.mNumObjects);
     317        mData.mNumObjects--;
     318        itProcs->second->onRemove();
     319        itProcs->second->uninit();
    310320    }
    311321    mData.mProcesses.clear();
    312322
    313     LogFlowThisFunc(("mNumObjects=%RU32\n", mData.mNumObjects));
     323    AssertMsg(mData.mNumObjects == 0,
     324              ("mNumObjects=%RU32 when it should be 0\n", mData.mNumObjects));
    314325
    315326    baseUninit();
    316 
    317     if (!mEventSource.isNull())
    318     {
    319         mEventSource->UnregisterListener(mLocalListener);
    320 
    321         mLocalListener.setNull();
    322         unconst(mEventSource).setNull();
    323     }
    324327#endif /* VBOX_WITH_GUEST_CONTROL */
    325328    LogFlowFuncLeaveRC(rc);
     
    661664    if (mData.mStatus != GuestSessionStatus_Started)
    662665    {
    663         LogFlowThisFunc(("Session ID=%RU32 not started (anymore), status now is: %ld\n",
     666        LogFlowThisFunc(("Session ID=%RU32 not started (anymore), status now is: %RU32\n",
    664667                         mData.mSession.mID, mData.mStatus));
    665668        return VINF_SUCCESS;
     
    721724    {
    722725        /* Construct arguments. */
    723         if (uFlags & DirectoryCreateFlag_Parents)
    724             procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */
     726        if (uFlags)
     727        {
     728            if (uFlags & DirectoryCreateFlag_Parents)
     729                procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */
     730            else
     731                vrc = VERR_INVALID_PARAMETER;
     732        }
     733       
    725734        if (uMode)
    726735        {
     
    780789    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    781790
    782     for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
    783          itDirs != mData.mDirectories.end(); ++itDirs)
     791    int rc = VERR_NOT_FOUND;
     792
     793    SessionDirectories::iterator itDirs = mData.mDirectories.begin();
     794    while (itDirs != mData.mDirectories.end())
    784795    {
    785796        if (pDirectory == itDirs->second)
    786797        {
     798            /* Make sure to consume the pointer before the one of the
     799             * iterator gets released. */
     800            ComObjPtr<GuestDirectory> pDir = pDirectory;
     801
    787802            Bstr strName;
    788803            HRESULT hr = itDirs->second->COMGETTER(DirectoryName)(strName.asOutParam());
     
    790805
    791806            Assert(mData.mDirectories.size());
    792             LogFlowFunc(("Removing directory \"%s\" (Session: %RU32) (now total %ld directories)\n",
    793                          Utf8Str(strName).c_str(), mData.mSession.mID, mData.mDirectories.size() - 1));
    794 
     807            Assert(mData.mNumObjects);
     808            LogFlowFunc(("Removing directory \"%s\" (Session: %RU32) (now total %zu processes, %ld objects)\n",
     809                         Utf8Str(strName).c_str(), mData.mSession.mID, mData.mDirectories.size() - 1, mData.mNumObjects - 1));
     810 
     811            rc = pDirectory->onRemove();
    795812            mData.mDirectories.erase(itDirs);
    796             return VINF_SUCCESS;
    797         }
    798     }
    799 
    800     return VERR_NOT_FOUND;
     813            mData.mNumObjects--;
     814
     815            pDir.setNull();
     816            break;
     817        }
     818
     819        itDirs++;
     820    }
     821
     822    LogFlowFuncLeaveRC(rc);
     823    return rc;
    801824}
    802825
     
    11711194    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    11721195
    1173     for (SessionFiles::iterator itFiles = mData.mFiles.begin();
    1174          itFiles != mData.mFiles.end(); ++itFiles)
     1196    int rc = VERR_NOT_FOUND;   
     1197
     1198    SessionFiles::iterator itFiles = mData.mFiles.begin();
     1199    while (itFiles != mData.mFiles.end())
    11751200    {
    11761201        if (pFile == itFiles->second)
     
    11881213                             Utf8Str(strName).c_str(), mData.mSession.mID, mData.mFiles.size() - 1, mData.mNumObjects - 1));
    11891214
    1190             pFile->cancelWaitEvents();
    1191             pFile->Release();
    1192 
     1215            rc = pFile->onRemove();
    11931216            mData.mFiles.erase(itFiles);
    11941217            mData.mNumObjects--;
     
    11981221            fireGuestFileRegisteredEvent(mEventSource, this, pCurFile,
    11991222                                         false /* Unregistered */);
    1200             return VINF_SUCCESS;
    1201         }
    1202     }
    1203 
    1204     return VERR_NOT_FOUND;
     1223            pCurFile.setNull();           
     1224            break;
     1225        }
     1226
     1227        itFiles++;
     1228    }
     1229
     1230    LogFlowFuncLeaveRC(rc);
     1231    return rc;   
    12051232}
    12061233
     
    14851512
    14861513    return S_OK;
     1514}
     1515
     1516/**
     1517 * Called by IGuest right before this session gets removed from
     1518 * the public session list.
     1519 */
     1520int GuestSession::onRemove(void)
     1521{
     1522    LogFlowThisFuncEnter();
     1523
     1524    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     1525
     1526    int vrc = VINF_SUCCESS;
     1527
     1528    /*
     1529     * Note: The event source stuff holds references to this object,
     1530     *       so make sure that this is cleaned up *before* calling uninit.
     1531     */
     1532    if (!mEventSource.isNull())
     1533    {
     1534        mEventSource->UnregisterListener(mLocalListener);
     1535
     1536        mLocalListener.setNull();
     1537        unconst(mEventSource).setNull();
     1538    }
     1539
     1540    LogFlowFuncLeaveRC(vrc);
     1541    return vrc;
    14871542}
    14881543
     
    17561811    ComAssertComRC(hr);
    17571812
    1758     LogFlowFunc(("Closing process (PID=%RU32) ...\n", uPID));
     1813    LogFlowFunc(("Removing process (PID=%RU32) ...\n", uPID));
    17591814
    17601815    SessionProcesses::iterator itProcs = mData.mProcesses.begin();
     
    17631818        if (pProcess == itProcs->second)
    17641819        {
    1765             /* Make sure to consume the pointer before the one of thfe
     1820#ifdef DEBUG_andy
     1821            ULONG cRefs = pProcess->AddRef();
     1822            Assert(cRefs >= 2);
     1823            LogFlowFunc(("pProcess=%p, cRefs=%RU32\n", pProcess, cRefs - 1));
     1824            pProcess->Release();
     1825#endif
     1826            /* Make sure to consume the pointer before the one of the
    17661827             * iterator gets released. */
    1767             ComObjPtr<GuestProcess> pCurProcess = pProcess;
    1768 
    1769             hr = pCurProcess->COMGETTER(PID)(&uPID);
     1828            ComObjPtr<GuestProcess> pProc = pProcess;
     1829
     1830            hr = pProc->COMGETTER(PID)(&uPID);
    17701831            ComAssertComRC(hr);
    17711832
     1833            Assert(mData.mProcesses.size());
    17721834            Assert(mData.mNumObjects);
    1773             LogFlowFunc(("Removing process ID=%RU32 (Session: %RU32), guest PID=%RU32 (now total %ld processes, %ld objects)\n",
     1835            LogFlowFunc(("Removing process ID=%RU32 (Session: %RU32), guest PID=%RU32 (now total %zu processes, %RU32 objects)\n",
    17741836                         pProcess->getObjectID(), mData.mSession.mID, uPID, mData.mProcesses.size() - 1, mData.mNumObjects - 1));
    17751837
    1776             pProcess->cancelWaitEvents();
    1777             pProcess->Release();
    1778 
     1838            rc = pProcess->onRemove();
    17791839            mData.mProcesses.erase(itProcs);
    17801840            mData.mNumObjects--;
     
    17821842            alock.release(); /* Release lock before firing off event. */
    17831843
    1784             fireGuestProcessRegisteredEvent(mEventSource, this /* Session */, pCurProcess,
     1844            fireGuestProcessRegisteredEvent(mEventSource, this /* Session */, pProc,
    17851845                                            uPID, false /* Process unregistered */);
    1786             rc = VINF_SUCCESS;
     1846            pProc.setNull();
    17871847            break;
    17881848        }
     
    19001960        Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS);
    19011961
    1902         LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes, %ld objects)\n",
     1962        LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %zu processes, %ld objects)\n",
    19031963                     mData.mSession.mID, uNewProcessID, mData.mProcesses.size(), mData.mNumObjects));
     1964
     1965        alock.release(); /* Release lock before firing off event. */
    19041966
    19051967        fireGuestProcessRegisteredEvent(mEventSource, this /* Session */, pProcess,
     
    19932055int GuestSession::setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc)
    19942056{
    1995     LogFlowThisFunc(("oldStatus=%ld, newStatus=%ld, sessionRc=%Rrc\n",
     2057    LogFlowThisFunc(("oldStatus=%RU32, newStatus=%RU32, sessionRc=%Rrc\n",
    19962058                     mData.mStatus, sessionStatus, sessionRc));
    19972059
     
    21782240
    21792241            default:
    2180                 AssertMsgFailed(("Unhandled session status %ld\n", mData.mStatus));
     2242                AssertMsgFailed(("Unhandled session status %RU32\n", mData.mStatus));
    21812243                return VERR_NOT_IMPLEMENTED;
    21822244        }
     
    22082270
    22092271            default:
    2210                 AssertMsgFailed(("Unhandled session status %ld\n", mData.mStatus));
     2272                AssertMsgFailed(("Unhandled session status %RU32\n", mData.mStatus));
    22112273                return VERR_NOT_IMPLEMENTED;
    22122274        }
    22132275    }
    22142276
    2215     LogFlowThisFunc(("sessionStatus=%ld, sessionRc=%Rrc, waitResult=%ld\n",
     2277    LogFlowThisFunc(("sessionStatus=%RU32, sessionRc=%Rrc, waitResult=%RU32\n",
    22162278                     mData.mStatus, mData.mRC, waitResult));
    22172279
     
    23182380            *pGuestRc = (int)lGuestRc;
    23192381
    2320         LogFlowThisFunc(("Status changed event for session ID=%RU32, new status is: %ld (%Rrc)\n",
     2382        LogFlowThisFunc(("Status changed event for session ID=%RU32, new status is: %RU32 (%Rrc)\n",
    23212383                         mData.mSession.mID, sessionStatus,
    23222384                         RT_SUCCESS((int)lGuestRc) ? VINF_SUCCESS : (int)lGuestRc));
     
    25202582        {
    25212583            case VERR_GSTCTL_GUEST_ERROR:
    2522                 hr = GuestProcess::setErrorExternal(this, guestRc);
     2584                /** @todo Handle VERR_NOT_EQUAL (meaning process exit code <> 0). */
     2585                hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Could not create directory"));
    25232586                break;
    25242587
     
    25292592            case VERR_BROKEN_PIPE:
    25302593               hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Unexpectedly aborted"));
    2531                break;
    2532 
    2533             case VERR_CANT_CREATE:
    2534                hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Could not create directory"));
    25352594               break;
    25362595
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