VirtualBox

Changeset 30071 in vbox


Ignore:
Timestamp:
Jun 7, 2010 1:29:23 PM (15 years ago)
Author:
vboxsync
Message:

Guest Control: Some todos.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/GuestImpl.cpp

    r30021 r30071  
    805805{
    806806    AssertPtr(pProgress);
    807     uint32_t uNewContext = ASMAtomicIncU32(&mNextContextID);
    808     if (uNewContext == UINT32_MAX)
    809         ASMAtomicUoWriteU32(&mNextContextID, 1000);
    810807
    811808    /** @todo Put this stuff into a constructor! */
    812809    CallbackContext context;
    813     context.mContextID = uNewContext;
    814810    context.mType = enmType;
    815811    context.pvData = pvData;
     
    817813    context.pProgress = pProgress;
    818814
    819     uint32_t nCallbacks;
    820     {
     815    /* Create a new context ID and assign it. */
     816    CallbackListIter it;
     817    uint32_t uNewContext = 0;
     818    do
     819    {   
     820        /* Create a new context ID ... */
     821        uNewContext = ASMAtomicIncU32(&mNextContextID);
     822        if (uNewContext == UINT32_MAX)
     823            ASMAtomicUoWriteU32(&mNextContextID, 1000);
     824        /* Is the context ID already used? */
     825        it = getCtrlCallbackContextByID(uNewContext);       
     826    } while(it != mCallbackList.end());
     827
     828    uint32_t nCallbacks = 0;
     829    if (   it == mCallbackList.end()
     830        && uNewContext > 0)
     831    {
     832        /* We apparently got an unused context ID, let's use it! */
     833        context.mContextID = uNewContext;
    821834        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    822         /// @todo r=bird: check if already in the list and find another one.
    823835        mCallbackList.push_back(context);
    824836        nCallbacks = mCallbackList.size();
     837    }
     838    else
     839    {
     840        /* Should never happen ... */
     841        {
     842            AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     843            nCallbacks = mCallbackList.size();
     844        }
     845        AssertReleaseMsg(uNewContext, ("No free context ID found! uNewContext=%u, nCallbacks=%u", uNewContext, nCallbacks));
    825846    }
    826847
     
    911932            AssertReturn(papszArgv, E_OUTOFMEMORY);
    912933            for (unsigned i = 0; RT_SUCCESS(vrc) && i < uNumArgs; i++)
    913             {
    914                 /// @todo r=bird: RTUtf16ToUtf8().
    915                 int cbLen = RTStrAPrintf(&papszArgv[i], "%s", Utf8Str(args[i]).raw());
    916                 if (cbLen < 0)
    917                     vrc = VERR_NO_MEMORY;
    918 
    919             }
     934                vrc = RTUtf16ToUtf8(args[i], &papszArgv[i]);
    920935            papszArgv[uNumArgs] = NULL;
    921936        }
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