VirtualBox

Ignore:
Timestamp:
Dec 14, 2018 8:34:20 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
127510
Message:

Main: bugref:6913: had to revert all changes for the defect because of crashing VBoxSVC on MacOS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r76239 r76240  
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1616 */
    17 
    18 #include <set>
    19 #include <map>
    2017
    2118#include "Logging.h"
     
    16401637    BOOL fSuspendedBySave     = FALSE;
    16411638
    1642     std::set<ComObjPtr<Medium> > pMediumsForNotify;
    1643     std::map<Guid, DeviceType_T> uIdsForNotify;
    1644 
    16451639    try
    16461640    {
     
    17791773            if (FAILED(rc))
    17801774                throw rc;
    1781         }
    1782 
    1783         // store parent of newly created diffs before commit for notify
    1784         {
    1785             MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData();
    1786             for (MediumAttachmentList::const_iterator
    1787                  it = mMediumAttachments->begin();
    1788                  it != mMediumAttachments->end();
    1789                  ++it)
    1790             {
    1791                 MediumAttachment *pAttach = *it;
    1792                 Medium *pMedium = pAttach->i_getMedium();
    1793                 if (!pMedium)
    1794                     continue;
    1795 
    1796                 bool fFound = false;
    1797                 /* was this medium attached before? */
    1798                 for (MediumAttachmentList::iterator
    1799                      oldIt = oldAtts.begin();
    1800                      oldIt != oldAtts.end();
    1801                      ++oldIt)
    1802                 {
    1803                     MediumAttachment *pOldAttach = *oldIt;
    1804                     if (pOldAttach->i_getMedium() == pMedium)
    1805                     {
    1806                         fFound = true;
    1807                         break;
    1808                     }
    1809                 }
    1810                 if (!fFound)
    1811                 {
    1812                     pMediumsForNotify.insert(pMedium->i_getParent());
    1813                     uIdsForNotify[pMedium->i_getId()] = pMedium->i_getDeviceType();
    1814                 }
    1815             }
    18161775        }
    18171776
     
    19171876    if (SUCCEEDED(rc))
    19181877        mParent->i_onSnapshotTaken(mData->mUuid, task.m_uuidSnapshot);
    1919 
    1920     if (SUCCEEDED(rc))
    1921     {
    1922         for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin();
    1923              it != uIdsForNotify.end();
    1924              ++it)
    1925         {
    1926             mParent->i_onMediumRegistered(it->first, it->second, TRUE);
    1927         }
    1928 
    1929         for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin();
    1930              it != pMediumsForNotify.end();
    1931              ++it)
    1932         {
    1933             if (it->isNotNull())
    1934                 mParent->i_onMediumConfigChanged(*it);
    1935         }
    1936     }
    19371878    LogFlowThisFuncLeave();
    19381879}
     
    21792120    HRESULT rc = S_OK;
    21802121    Guid snapshotId;
    2181     std::set<ComObjPtr<Medium> > pMediumsForNotify;
    2182     std::map<Guid, DeviceType_T> uIdsForNotify;
    21832122
    21842123    try
     
    22752214            /* make the snapshot we restored from the current snapshot */
    22762215            mData->mCurrentSnapshot = task.m_pSnapshot;
    2277         }
    2278 
    2279         // store parent of newly created diffs for notify
    2280         {
    2281             MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData();
    2282             for (MediumAttachmentList::const_iterator
    2283                  it = mMediumAttachments->begin();
    2284                  it != mMediumAttachments->end();
    2285                  ++it)
    2286             {
    2287                 MediumAttachment *pAttach = *it;
    2288                 Medium *pMedium = pAttach->i_getMedium();
    2289                 if (!pMedium)
    2290                     continue;
    2291 
    2292                 bool fFound = false;
    2293                 /* was this medium attached before? */
    2294                 for (MediumAttachmentList::iterator
    2295                      oldIt = oldAtts.begin();
    2296                      oldIt != oldAtts.end();
    2297                      ++oldIt)
    2298                 {
    2299                     MediumAttachment *pOldAttach = *oldIt;
    2300                     if (pOldAttach->i_getMedium() == pMedium)
    2301                     {
    2302                         fFound = true;
    2303                         break;
    2304                     }
    2305                 }
    2306                 if (!fFound)
    2307                 {
    2308                     pMediumsForNotify.insert(pMedium->i_getParent());
    2309                     uIdsForNotify[pMedium->i_getId()] = pMedium->i_getDeviceType();
    2310                 }
    2311             }
    23122216        }
    23132217
     
    24102314            LogFlowThisFunc(("Deleting old current state in differencing image '%s'\n", pMedium->i_getName().c_str()));
    24112315
    2412             ComObjPtr<Medium> pParent = pMedium->i_getParent();
    24132316            HRESULT rc2 = pMedium->i_deleteStorage(NULL /* aProgress */,
    2414                                                    true /* aWait */,
    2415                                                    false /* aNotify */);
     2317                                                   true /* aWait */);
    24162318            // ignore errors here because we cannot roll back after i_saveSettings() above
    24172319            if (SUCCEEDED(rc2))
    2418             {
    2419                 pMediumsForNotify.insert(pParent);
    24202320                pMedium->uninit();
    2421             }
    24222321        }
    24232322    }
     
    24462345
    24472346    if (SUCCEEDED(rc))
    2448     {
    24492347        mParent->i_onSnapshotRestored(mData->mUuid, snapshotId);
    2450         for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin();
    2451              it != uIdsForNotify.end();
    2452              ++it)
    2453         {
    2454             mParent->i_onMediumRegistered(it->first, it->second, TRUE);
    2455         }
    2456         for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin();
    2457              it != pMediumsForNotify.end();
    2458              ++it)
    2459         {
    2460             if (it->isNotNull())
    2461                 mParent->i_onMediumConfigChanged(*it);
    2462         }
    2463     }
    24642348
    24652349    LogFlowThisFunc(("Done restoring snapshot (rc=%08X)\n", rc));
     
    28122696    MediumDeleteRecList toDelete;
    28132697    Guid snapshotId;
    2814     std::set<ComObjPtr<Medium> > pMediumsForNotify;
    2815     std::map<Guid,DeviceType_T> uIdsForNotify;
    28162698
    28172699    try
     
    31883070                    /* No need to hold the lock any longer. */
    31893071                    mLock.release();
    3190                     ComObjPtr<Medium> pParent = pMedium->i_getParent();
    3191                     Guid uMedium = pMedium->i_getId();
    3192                     DeviceType_T uMediumType = pMedium->i_getDeviceType();
    31933072                    rc = pMedium->i_deleteStorage(&task.m_pProgress,
    3194                                                   true /* aWait */,
    3195                                                   false /* aNotify */);
     3073                                                  true /* aWait */);
    31963074                    if (FAILED(rc))
    31973075                        throw rc;
    3198 
    3199                     pMediumsForNotify.insert(pParent);
    3200                     uIdsForNotify[uMedium] = uMediumType;
    32013076
    32023077                    // need to uninit the deleted medium
     
    32063081            else
    32073082            {
    3208                 {
    3209                     //store ids before merging for notify
    3210                     pMediumsForNotify.insert(it->mpTarget);
    3211                     if (it->mfMergeForward)
    3212                         pMediumsForNotify.insert(it->mpSource->i_getParent());
    3213                     else
    3214                     {
    3215                         //children which will be reparented to target
    3216                         for (MediaList::const_iterator iit = it->mpSource->i_getChildren().begin();
    3217                              iit != it->mpSource->i_getChildren().end();
    3218                              ++iit)
    3219                         {
    3220                             pMediumsForNotify.insert(*iit);
    3221                         }
    3222                     }
    3223                     if (it->mfMergeForward)
    3224                     {
    3225                         for (ComObjPtr<Medium> pTmpMedium = it->mpTarget->i_getParent();
    3226                              pTmpMedium != it->mpSource;
    3227                              pTmpMedium = pTmpMedium->i_getParent())
    3228                         {
    3229                             uIdsForNotify[pTmpMedium->i_getId()] = pTmpMedium->i_getDeviceType();
    3230                         }
    3231                         uIdsForNotify[it->mpSource->i_getId()] = it->mpSource->i_getDeviceType();
    3232                     }
    3233                     else
    3234                     {
    3235                         for (ComObjPtr<Medium> pTmpMedium = it->mpSource->i_getParent();
    3236                              pTmpMedium != it->mpTarget;
    3237                              pTmpMedium = pTmpMedium->i_getParent())
    3238                         {
    3239                             uIdsForNotify[pTmpMedium->i_getId()] = pTmpMedium->i_getDeviceType();
    3240                         }
    3241                     }
    3242                 }
    3243 
    32443083                bool fNeedsSave = false;
    32453084                if (it->mfNeedsOnlineMerge)
     
    32723111                                                 it->mpMediumLockList,
    32733112                                                 &task.m_pProgress,
    3274                                                  true /* aWait */,
    3275                                                  false /* aNotify */);
     3113                                                 true /* aWait */);
    32763114                }
    32773115
     
    34403278
    34413279    if (SUCCEEDED(mrc))
    3442     {
    34433280        mParent->i_onSnapshotDeleted(mData->mUuid, snapshotId);
    3444         for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin();
    3445              it != uIdsForNotify.end();
    3446              ++it)
    3447         {
    3448             mParent->i_onMediumRegistered(it->first, it->second, FALSE);
    3449         }
    3450         for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin();
    3451              it != pMediumsForNotify.end();
    3452              ++it)
    3453         {
    3454             if (it->isNotNull())
    3455                 mParent->i_onMediumConfigChanged(*it);
    3456         }
    3457     }
    34583281
    34593282    LogFlowThisFunc(("Done deleting snapshot (rc=%08X)\n", (HRESULT)mrc));
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