mattrpav commented on code in PR #1884:
URL: https://github.com/apache/karaf/pull/1884#discussion_r1840864589


##########
shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java:
##########
@@ -189,6 +194,20 @@ protected SshServer createSshServer(SessionFactory 
sessionFactory) {
         
server.setKeyExchangeFactories(SshUtils.buildKexAlgorithms(kexAlgorithms));
         
server.setSignatureFactories(SshUtils.buildSigAlgorithms(sigAlgorithms));
         server.setShellFactory(new ShellFactoryImpl(sessionFactory));
+        server.addSessionListener(new SessionListener() {
+            @Override
+            public void 
sessionDisconnect(org.apache.sshd.common.session.Session session, int reason, 
String msg, String language, boolean initiator) {
+                try {
+                    Collection<ServiceReference<ChannelResourceCleaner>> 
references = bundleContext.getServiceReferences(ChannelResourceCleaner.class, 
null);
+                    for (ServiceReference<ChannelResourceCleaner> reference : 
references) {
+                        ChannelResourceCleaner cleaner = 
bundleContext.getService(reference);
+                        cleaner.close();

Review Comment:
   Sounds good, a SSH sessionId stored in the command session state should do 
it.. then when the close loops, look for the matching one and close _only_ that 
one. 
   
   Also, probably need a test with two sessions running.. first one aborts and 
second one stays active to confirm only the first one gets .close() called on 
it.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to