Browse Source

fixed auto-interest remove

aignacio_sf 19 years ago
parent
commit
1d7c9f7e76
1 changed files with 14 additions and 12 deletions
  1. 14 12
      direct/src/distributed/DoInterestManager.py

+ 14 - 12
direct/src/distributed/DoInterestManager.py

@@ -186,11 +186,10 @@ class DoInterestManager(DirectObject.DirectObject):
         """
         """
         Stop looking in a (set of) zone(s)
         Stop looking in a (set of) zone(s)
         """
         """
-
         assert DoInterestManager.notify.debugCall()
         assert DoInterestManager.notify.debugCall()
         assert isinstance(handle, InterestHandle)
         assert isinstance(handle, InterestHandle)
         existed = False
         existed = False
-        if event is None:
+        if ((not auto) and (event is None)):
             event = self._getAnonymousEvent('removeInterest')
             event = self._getAnonymousEvent('removeInterest')
         handle = handle.asInt()
         handle = handle.asInt()
         if DoInterestManager._interests.has_key(handle):
         if DoInterestManager._interests.has_key(handle):
@@ -215,18 +214,20 @@ class DoInterestManager(DirectObject.DirectObject):
                     self.notify.warning('removeInterest: abandoning events: %s' %
                     self.notify.warning('removeInterest: abandoning events: %s' %
                                         intState.events)
                                         intState.events)
                     intState.clearEvents()
                     intState.clearEvents()
-                scopeId = self._getNextScopeId()
                 intState.state = InterestState.StatePendingDel
                 intState.state = InterestState.StatePendingDel
-                intState.scope = scopeId
-                if event is not None:
-                    intState.addEvent(event)
+                if auto:
+                    self._considerRemoveInterest(handle)
+                else:
+                    scopeId = self._getNextScopeId()
+                    intState.scope = scopeId
+                    if event is not None:
+                        intState.addEvent(event)
+                    self._sendRemoveInterest(handle, scopeId)
+                    if event is None:
+                        self._considerRemoveInterest(handle)
                 if self.InterestDebug:
                 if self.InterestDebug:
                     print 'INTEREST DEBUG: removeInterest(): handle=%s, event=%s' % (
                     print 'INTEREST DEBUG: removeInterest(): handle=%s, event=%s' % (
                         handle, event)
                         handle, event)
-                if not auto:
-                    self._sendRemoveInterest(handle, scopeId)
-                if event is None:
-                    self._considerRemoveInterest(handle)
         else:
         else:
             DoInterestManager.notify.warning(
             DoInterestManager.notify.warning(
                 "removeInterest: handle not found: %s" % (handle))
                 "removeInterest: handle not found: %s" % (handle))
@@ -250,7 +251,7 @@ class DoInterestManager(DirectObject.DirectObject):
             DoInterestManager.notify.warning(
             DoInterestManager.notify.warning(
                 "alterInterest: addingInterests on delete: %s" % (handle))
                 "alterInterest: addingInterests on delete: %s" % (handle))
             return
             return
-        
+
         exists = False
         exists = False
         if event is None:
         if event is None:
             event = self._getAnonymousEvent('alterInterest')
             event = self._getAnonymousEvent('alterInterest')
@@ -334,6 +335,7 @@ class DoInterestManager(DirectObject.DirectObject):
         Consider whether we should cull the interest set.
         Consider whether we should cull the interest set.
         """
         """
         assert DoInterestManager.notify.debugCall()
         assert DoInterestManager.notify.debugCall()
+        
         if DoInterestManager._interests.has_key(handle):
         if DoInterestManager._interests.has_key(handle):
             if DoInterestManager._interests[handle].isPendingDelete():
             if DoInterestManager._interests[handle].isPendingDelete():
                 # make sure there is no pending event for this interest
                 # make sure there is no pending event for this interest
@@ -369,7 +371,7 @@ class DoInterestManager(DirectObject.DirectObject):
             print "******************* Interest Sets **************"
             print "******************* Interest Sets **************"
             format = '%6s %' + str(DoInterestManager._debug_maxDescriptionLen) + 's %10s %5s %9s %9s %10s'
             format = '%6s %' + str(DoInterestManager._debug_maxDescriptionLen) + 's %10s %5s %9s %9s %10s'
             print format % (
             print format % (
-                "Handle", "Description", "State", "Scope", 
+                "Handle", "Description", "State", "Scope",
                 "ParentId", "ZoneIdList", "Event")
                 "ParentId", "ZoneIdList", "Event")
             for id, state in DoInterestManager._interests.items():
             for id, state in DoInterestManager._interests.items():
                 if len(state.events) == 0:
                 if len(state.events) == 0: