VirtualBox

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


Ignore:
Timestamp:
Feb 7, 2012 4:02:30 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76142
Message:

GuestCtrl/Main: Fixed some locking issues + callback cleanup hangs; fixed a memory leak on callback creation.

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

Legend:

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

    r39991 r40020  
    116116    /* puContextID is optional. */
    117117
    118     int rc;
     118    int rc = VERR_NOT_FOUND;
     119
     120    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    119121
    120122    /* Create a new context ID and assign it. */
     
    139141    if (RT_SUCCESS(rc))
    140142    {
    141         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    142 
    143143        /* Add callback with new context ID to our callback map. */
    144144        mCallbackMap[uNewContextID] = *pCallback;
     
    154154
    155155/**
     156 * Destroys the formerly allocated callback data. The callback then
     157 * needs to get removed from the callback map via callbackRemove().
    156158 * Does not do locking!
    157159 *
     
    173175            it->second.cbData = 0;
    174176        }
    175 
    176         /* Remove callback context (not used anymore). */
    177         mCallbackMap.erase(it);
    178     }
     177    }
     178}
     179
     180/**
     181 * Removes a callback from the callback map.
     182 * Does not do locking!
     183 *
     184 * @param   uContextID
     185 */
     186void Guest::callbackRemove(uint32_t uContextID)
     187{
     188    callbackDestroy(uContextID);
     189
     190    mCallbackMap.erase(uContextID);
    179191}
    180192
     
    17081720                    vrc = callbackInit(&callback, VBOXGUESTCTRLCALLBACKTYPE_EXEC_START, pProgress);
    17091721                    if (RT_SUCCESS(vrc))
    1710                     {
    1711                         /* Allocate and assign payload. */
    1712                         callback.cbData = sizeof(CALLBACKDATAEXECSTATUS);
    1713                         PCALLBACKDATAEXECSTATUS pData = (PCALLBACKDATAEXECSTATUS)RTMemAlloc(callback.cbData);
    1714                         AssertReturn(pData, E_OUTOFMEMORY);
    1715                         RT_BZERO(pData, callback.cbData);
    1716                         callback.pvData = pData;
    1717                     }
    1718 
    1719                     if (RT_SUCCESS(vrc))
    17201722                        vrc = callbackAdd(&callback, &uContextID);
    17211723
     
    20122014            }
    20132015
    2014             /* The callback isn't needed anymore -- just was kept locally. */
    2015             callbackDestroy(uContextID);
     2016            {
     2017                AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2018
     2019                /* The callback isn't needed anymore -- just was kept locally. */
     2020                callbackRemove(uContextID);
     2021            }
    20162022
    20172023            /* Cleanup. */
     
    22072213                rc = handleErrorHGCM(vrc);
    22082214
    2209             /* The callback isn't needed anymore -- just was kept locally. */
    2210             callbackDestroy(uContextID);
     2215            {
     2216                AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2217
     2218                /* The callback isn't needed anymore -- just was kept locally. */
     2219                callbackRemove(uContextID);
     2220            }
    22112221
    22122222            /* Cleanup. */
  • trunk/src/VBox/Main/src-client/GuestImpl.cpp

    r39898 r40020  
    118118    LogFlowThisFunc(("\n"));
    119119
     120    /* Enclose the state transition Ready->InUninit->NotReady */
     121    AutoUninitSpan autoUninitSpan(this);
     122    if (autoUninitSpan.uninitDone())
     123        return;
     124
    120125#ifdef VBOX_WITH_GUEST_CONTROL
    121     /* r=poetzsch: Not sure if this is really right. Please note that
    122      * IGuest::uninit is called twice (which I also consider a bug). So the
    123      * test for uninitDone should be always first! */
    124126    /* Scope write lock as much as possible. */
    125127    {
     
    144146            callbackDestroy(it->first);
    145147
    146         /* Clear process map. */
     148        /* Clear process map (remove all callbacks). */
    147149        mGuestProcessMap.clear();
    148150    }
    149151#endif
    150 
    151     /* Enclose the state transition Ready->InUninit->NotReady */
    152     AutoUninitSpan autoUninitSpan(this);
    153     if (autoUninitSpan.uninitDone())
    154         return;
    155152
    156153#ifdef VBOX_WITH_DRAG_AND_DROP
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette