Skip to content

Commit 38084bd

Browse files
committedMay 28, 2018
terminate linkedSession if appropiate...
1 parent 24fe1b8 commit 38084bd

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed
 

‎sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java

+16-13
Original file line numberDiff line numberDiff line change
@@ -1592,8 +1592,22 @@ public void onTerminatedState() {
15921592
}
15931593
//switch to readyToInvalidate state here
15941594
this.setReadyToInvalidate(true);
1595+
1596+
//make sure linked session is terminated as well so is
1597+
//not left on memory
1598+
MobicentsSipSession linkedSession = null;
1599+
if (this.b2buaHelper != null) {
1600+
//save ref to linkedSession for later
1601+
linkedSession = (MobicentsSipSession) this.b2buaHelper.getLinkedSession(this);
1602+
}
15951603
//evaluate if we can proceed to invalidation
15961604
onReadyToInvalidate();
1605+
1606+
//invoke after actual invalidation to prevent infinite loop
1607+
if (linkedSession != null) {
1608+
//linkedSession.onTerminatedState();
1609+
}
1610+
15971611
if(!this.isValid && this.parentSession != null) {
15981612
//Since there is a parent session, and since the current derived sip session
15991613
//is already invalidated, ask the parent session to invalidate.
@@ -1603,19 +1617,8 @@ public void onTerminatedState() {
16031617
String msg = String.format("SipSession [%s] onTerminateState hasParentSession [%s] that will ask to onReadyToInvalidate()", key, parentSession.getKey());
16041618
logger.debug(msg);
16051619
}
1606-
Iterator<MobicentsSipSession> derivedSessionsIterator = parentSession.getDerivedSipSessions();
1607-
boolean allDerivedTerminated = true;
1608-
while (derivedSessionsIterator.hasNext()) {
1609-
MobicentsSipSession derivedSession = (MobicentsSipSession) derivedSessionsIterator
1610-
.next();
1611-
if(!derivedSession.isValidInternal() || !derivedSession.isReadyToInvalidate()) {
1612-
allDerivedTerminated = allDerivedTerminated && false;
1613-
}
1614-
}
1615-
// Calling this.parentSession.onReadyToInvalidate(); will check whether or not there are derived sip sessions
1616-
if (allDerivedTerminated) {
1617-
this.parentSession.onTerminatedState();
1618-
}
1620+
1621+
this.parentSession.onReadyToInvalidate();
16191622
}
16201623
}
16211624
}

0 commit comments

Comments
 (0)
Please sign in to comment.