VirtualBox

Changeset 77096 in vbox


Ignore:
Timestamp:
Feb 1, 2019 9:14:03 AM (6 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Use the new code path of GuestBase::signalWaitEvent(); it's a lot cleaner and should deal with error conditions better.

File:
1 edited

Legend:

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

    r77095 r77096  
    10361036        if (itGroup != mWaitEventGroups.end())
    10371037        {
    1038 #if 1 /** @todo r=bird: consider the other variant. */
    1039             GuestWaitEvents::iterator itEvents = itGroup->second.begin();
    1040             while (itEvents != itGroup->second.end())
    1041             {
    1042 #ifdef DEBUG
    1043                 LogFlowThisFunc(("Signalling event=%p, type=%ld (CID %RU32: Session=%RU32, Object=%RU32, Count=%RU32) ...\n",
    1044                                  itEvents->second, aType, itEvents->first,
    1045                                  VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(itEvents->first),
    1046                                  VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(itEvents->first),
    1047                                  VBOX_GUESTCTRL_CONTEXTID_GET_COUNT(itEvents->first)));
    1048 #endif
    1049                 ComPtr<IEvent> pThisEvent = aEvent; /** @todo r=bird: This means addref/release for each iteration. Isn't that silly? */
    1050                 Assert(!pThisEvent.isNull());
    1051                 int rc2 = itEvents->second->SignalExternal(aEvent);
    1052                 if (RT_SUCCESS(rc))
    1053                     rc = rc2; /** @todo r=bird: This doesn't make much sense since it will only fail if not
    1054                                * properly initialized or major memory corruption.  And if it's broken, why
    1055                                * don't you just remove it instead of leaving it in the group???  It would
    1056                                * make life so much easier here as you could just change the while condition
    1057                                * to while ((itEvents = itGroup->second.begin() != itGroup->second.end())
    1058                                * and skip all this two step removal below.  I'll put this in a #if 0 and show what I mean... */
    1059 
    1060                 if (RT_SUCCESS(rc2))
    1061                 {
    1062                     /** @todo r=bird: I don't follow the logic here.  Why don't you just remove
    1063                      *        it from all groups, including this one?  You just have move the  */
    1064 
    1065                     /* Remove the event from all other event groups (except the
    1066                      * original one!) because it was signalled. */
    1067                     AssertPtr(itEvents->second);
    1068                     const GuestEventTypes evTypes = itEvents->second->Types();
    1069                     for (GuestEventTypes::const_iterator itType = evTypes.begin();
    1070                          itType != evTypes.end(); ++itType)
    1071                     {
    1072                         if ((*itType) != aType) /* Only remove all other groups. */
    1073                         {
    1074                             /* Get current event group. */
    1075                             GuestEventGroup::iterator evGroup = mWaitEventGroups.find((*itType));
    1076                             Assert(evGroup != mWaitEventGroups.end());
    1077 
    1078                             /* Lookup event in event group. */
    1079                             GuestWaitEvents::iterator evEvent = evGroup->second.find(itEvents->first /* Context ID */);
    1080                             Assert(evEvent != evGroup->second.end());
    1081 
    1082                             LogFlowThisFunc(("Removing event=%p (type %ld)\n", evEvent->second, (*itType)));
    1083                             evGroup->second.erase(evEvent);
    1084 
    1085                             LogFlowThisFunc(("%zu events for type=%ld left\n",
    1086                                              evGroup->second.size(), aType));
    1087                         }
    1088                     }
    1089 
    1090                     /* Remove the event from the passed-in event group. */
    1091                     GuestWaitEvents::iterator itEventsNext = itEvents;
    1092                     ++itEventsNext;
    1093                     itGroup->second.erase(itEvents);
    1094                     itEvents = itEventsNext;
    1095                 }
    1096                 else
    1097                     ++itEvents;
    1098 #ifdef DEBUG
    1099                 cEvents++;
    1100 #endif
    1101             }
    1102 #else
    11031038            /* Signal all events in the group, leaving the group empty afterwards. */
    11041039            GuestWaitEvents::iterator ItWaitEvt;
     
    11331068                }
    11341069            }
    1135 #endif
    11361070        }
    11371071
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