Skip to content

Commit

Permalink
fix: Fix leaking conferences. (#978)
Browse files Browse the repository at this point in the history
* fix: Fix leaking conferences.

I don't understand how the leak occurs, but I see multiple conferences
left as listeners of XmppProviderImpl, which are not in FocusManager
anymore. Fire events via FocusManager instead of registering individual
conferences.
  • Loading branch information
bgrozev authored Sep 27, 2022
1 parent 9f75952 commit 0eb385f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @author Pawel Domas
*/
public interface JitsiMeetConference
public interface JitsiMeetConference extends RegistrationListener
{
/**
* Checks how many {@link Participant}s are in the conference.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ public void start()
joinTheRoom();
}

clientXmppProvider.addRegistrationListener(this);

JibriDetector jibriDetector = jicofoServices.getJibriDetector();
if (jibriDetector != null)
{
Expand Down Expand Up @@ -404,8 +402,6 @@ public void stop()
jibriRecorder = null;
}

getClientXmppProvider().removeRegistrationListener(this);

BridgeSelector bridgeSelector = jicofoServices.getBridgeSelector();
bridgeSelector.removeHandler(bridgeSelectorEventHandler);

Expand Down
8 changes: 7 additions & 1 deletion jicofo/src/main/kotlin/org/jitsi/jicofo/FocusManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.jitsi.jicofo

import org.jitsi.impl.protocol.xmpp.RegistrationListener
import org.jitsi.jicofo.conference.ConferenceMetrics
import org.jitsi.jicofo.conference.JitsiMeetConference
import org.jitsi.jicofo.conference.JitsiMeetConferenceImpl
Expand Down Expand Up @@ -49,7 +50,7 @@ import java.util.logging.Level
class FocusManager @JvmOverloads constructor(
/** Clock to use for pin timeouts. */
private val clock: Clock = Clock.systemUTC()
) : ConferenceListener, ConferenceStore {
) : ConferenceListener, ConferenceStore, RegistrationListener {

val logger = createLogger()

Expand Down Expand Up @@ -399,6 +400,7 @@ class FocusManager @JvmOverloads constructor(
// Loop over conferences
conferenceCopy.filterNot { it.hasHadAtLeastOneParticipant() }.forEach { it ->
if (Duration.between(it.creationTime, Instant.now()) > timeout) {
logger.info("Expiring $it")
it.stop()
}
}
Expand All @@ -418,4 +420,8 @@ class FocusManager @JvmOverloads constructor(
/** When this pinning expires. */
val expiresAt: Instant = clock.instant().plus(duration).truncatedTo(ChronoUnit.SECONDS)
}

override fun registrationChanged(registered: Boolean) {
conferencesCache.forEach { it.registrationChanged(registered) }
}
}
6 changes: 5 additions & 1 deletion jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ open class JicofoServices {
conferenceStore = focusManager,
focusManager = focusManager, // TODO do not use FocusManager directly
authenticationAuthority = authenticationAuthority
)
).also {
it.clientConnection.addRegistrationListener(focusManager)
}

val bridgeSelector = BridgeSelector()
private val jvbDoctor = if (BridgeConfig.config.healthChecksEnabled) {
Expand Down Expand Up @@ -168,6 +170,8 @@ open class JicofoServices {
bridgeDetector?.shutdown()
jibriDetector?.shutdown()
sipJibriDetector?.shutdown()
xmppServices.clientConnection.removeRegistrationListener(focusManager)
focusManager.stop()
xmppServices.shutdown()
}

Expand Down

0 comments on commit 0eb385f

Please sign in to comment.