[
https://issues.apache.org/jira/browse/KARAF-7174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17897978#comment-17897978
]
ASF GitHub Bot commented on KARAF-7174:
---------------------------------------
jbonofre commented on code in PR #1884:
URL: https://github.com/apache/karaf/pull/1884#discussion_r1840787693
##########
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:
That's right it's a bit agressive: if we have several ssh clients on the
Karaf ssh server, we will close *all* references whatever is the client.
It's pretty hard to "link" the session with the command (or maybe we can use
a session property to identify the correct session).
> log:tail threads keep running after ssh exits
> ---------------------------------------------
>
> Key: KARAF-7174
> URL: https://issues.apache.org/jira/browse/KARAF-7174
> Project: Karaf
> Issue Type: Bug
> Components: karaf
> Affects Versions: 4.3.2
> Environment: Ubuntu 20.04.2 LTS
> Clean out-of-the-box Karaf 4.3.2 distribution
> Reporter: Gabriel Andrade
> Assignee: Jean-Baptiste Onofré
> Priority: Critical
> Attachments: log-tail stack trace.txt
>
>
> When executing log:tail via Karaf's ssh connection, the created thread is not
> killed when the ssh connection is killed or timeouts.
> I believe that all threads launched via ssh should be killed if the session
> is no longer active.
> Steps to reproduce:
> * Open a ssh connection with Karaf
> * {{Run log:tail}}
> * Either close the session without exiting log:tail or wait until it
> timeouts in a few minutes;
> * {{Run shell:threads | grep log:tail on the console or another ssh
> connection}}
> * A log tail thread should still be running.
> Every time this process is repeated, a new log:tail thread will appear and
> stay alive.
> I've attached the return of one of my shell:thread commands.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)