/** * Closes given {@link #transportManagers} of this <tt>Conference</tt> and removes corresponding * channel bundle. */ void closeTransportManager(TransportManager transportManager) { synchronized (transportManagers) { for (Iterator<IceUdpTransportManager> i = transportManagers.values().iterator(); i.hasNext(); ) { if (i.next() == transportManager) { i.remove(); // Presumably, we have a single association for // transportManager. break; } } // Close manager try { transportManager.close(); } catch (Throwable t) { logger.warn( "Failed to close an IceUdpTransportManager of" + " conference " + getID() + "!", t); // The whole point of explicitly closing the // transportManagers of this Conference is to prevent memory // leaks. Hence, it does not make sense to possibly leave // TransportManagers open because a TransportManager has // failed to close. if (t instanceof InterruptedException) Thread.currentThread().interrupt(); else if (t instanceof ThreadDeath) throw (ThreadDeath) t; } } }
void stop() { if (timeoutThread == null) { return; } enabled = false; synchronized (sleepLock) { sleepLock.notifyAll(); } try { if (Thread.currentThread() != timeoutThread) { timeoutThread.join(); } timeoutThread = null; } catch (InterruptedException e) { throw new RuntimeException(e); } }
/** * Expires this <tt>Conference</tt>, its <tt>Content</tt>s and their respective <tt>Channel</tt>s. * Releases the resources acquired by this instance throughout its life time and prepares it to be * garbage collected. */ public void expire() { synchronized (this) { if (expired) return; else expired = true; } EventAdmin eventAdmin = videobridge.getEventAdmin(); if (eventAdmin != null) eventAdmin.sendEvent(EventFactory.conferenceExpired(this)); setRecording(false); if (recorderEventHandler != null) { recorderEventHandler.close(); recorderEventHandler = null; } Videobridge videobridge = getVideobridge(); try { videobridge.expireConference(this); } finally { // Expire the Contents of this Conference. for (Content content : getContents()) { try { content.expire(); } catch (Throwable t) { logger.warn( "Failed to expire content " + content.getName() + " of conference " + getID() + "!", t); if (t instanceof InterruptedException) Thread.currentThread().interrupt(); else if (t instanceof ThreadDeath) throw (ThreadDeath) t; } } // Close the transportManagers of this Conference. Normally, there // will be no TransportManager left to close at this point because // all Channels have expired and the last Channel to be removed from // a TransportManager closes the TransportManager. However, a // Channel may have expired before it has learned of its // TransportManager and then the TransportManager will not close. closeTransportManagers(); if (logger.isInfoEnabled()) { logger.info( "Expired conference " + getID() + ". " + videobridge.getConferenceCountString()); } } }
void start() { if (timeoutThread != null) { throw new IllegalStateException(); } timeoutThread = new Thread( new Runnable() { @Override public void run() { expireLoop(); } }, "FocusExpireThread"); enabled = true; timeoutThread.start(); }
private void expireLoop() { while (enabled) { // Sleep try { synchronized (sleepLock) { sleepLock.wait(POLL_INTERVAL); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } if (!enabled) break; try { ArrayList<JitsiMeetConference> conferenceCopy; synchronized (FocusManager.this) { conferenceCopy = new ArrayList<JitsiMeetConference>(conferences.values()); } // Loop over conferences for (JitsiMeetConference conference : conferenceCopy) { long idleStamp = conference.getIdleTimestamp(); // Is active ? if (idleStamp == -1) { continue; } if (System.currentTimeMillis() - idleStamp > timeout) { logger.info("Focus idle timeout for " + conference.getRoomName()); conference.stop(); } } } catch (Exception ex) { logger.warn("Error while checking for timeouted conference", ex); } } }