From 67e5f839f11f0c458287d9e7e679317e0ece3e50 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 8 May 2021 11:50:18 +0200 Subject: [PATCH] ignore crypto callbacks when rtp session has already been terminated --- .../xmpp/jingle/JingleRtpConnection.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index 0d147d2af..67c32d72a 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -540,6 +540,9 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private void failureToAcceptSession(final Throwable throwable) { + if (isTerminated()) { + return; + } Log.d(Config.LOGTAG, "unable to send session accept", Throwables.getRootCause(throwable)); webRTCWrapper.close(); sendSessionTerminate(Reason.ofThrowable(throwable)); @@ -574,6 +577,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private void sendSessionAccept(final RtpContentMap rtpContentMap, final org.webrtc.SessionDescription webRTCSessionDescription) { + if (isTerminated()) { + Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": preparing session accept was too slow. already terminated. nothing to do."); + return; + } transitionOrThrow(State.SESSION_ACCEPTED); final JinglePacket sessionAccept = rtpContentMap.toJinglePacket(JinglePacket.Action.SESSION_ACCEPT, id.sessionId); send(sessionAccept); @@ -837,6 +844,9 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private void failureToInitiateSession(final Throwable throwable, final State targetState) { + if (isTerminated()) { + return; + } Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to sendSessionInitiate", Throwables.getRootCause(throwable)); webRTCWrapper.close(); final Reason reason = Reason.ofThrowable(throwable); @@ -873,6 +883,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private void sendSessionInitiate(final RtpContentMap rtpContentMap, final org.webrtc.SessionDescription webRTCSessionDescription, final State targetState) { + if (isTerminated()) { + Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": preparing session was too slow. already terminated. nothing to do."); + return; + } this.transitionOrThrow(targetState); final JinglePacket sessionInitiate = rtpContentMap.toJinglePacket(JinglePacket.Action.SESSION_INITIATE, id.sessionId); send(sessionInitiate);