internal static PortWatcher addPort(Session session, string address, int lport, string host, int rport, ServerSocketFactory ssf) { if (getPort(session, address, lport) != null) { throw new JSchException("PortForwardingL: local port " + address + ":" + lport + " is already registered."); } PortWatcher pw = new PortWatcher(session, address, lport, host, rport, ssf); m_pool.Add(pw); return pw; }
internal static void delPort(Session session) { lock (m_pool) { PortWatcher[] foo = new PortWatcher[m_pool.Count]; int count = 0; for (int i = 0; i < m_pool.Count; i++) { PortWatcher p = m_pool[i]; if (p.session == session) { p.delete(); foo[count++] = p; } } for (int i = 0; i < count; i++) { PortWatcher p = foo[i]; m_pool.Remove(p); } } }