[ https://issues.apache.org/jira/browse/DIRMINA-708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12711393#action_12711393 ]
Emmanuel Lecharny commented on DIRMINA-708: ------------------------------------------- A quick look at the code shows that if the thread is locked, it's because the flush() method is not called. Let's walk the code : We have a writeMonitor which is used in two places ; the WriteWorker and the SerialIoProcessor. - In the WriteWorker : ... // wait for more data synchronized (writeMonitor) { try { writeMonitor.wait(); } catch (InterruptedException e) { log.error("InterruptedException", e); } } ... - in the SerialIoProcessor : ... public void flush(SerialSessionImpl session) { if (writeWorker == null) { writeWorker = new WriteWorker(); writeWorker.start(); } else { synchronized (writeMonitor) { writeMonitor.notifyAll(); } } } ... This flush method is called by the SerialIoProcessor.remove() method, and the flush method is the only place the WriterWorker is created. Now note the sequence : 1) we start the SerialSessionImpl 2) It creates everything, and the remove() method is called when there is an exception 3) The remove() method do some cleaning, and call the flush() method (this is the only place this method is called) 4) The flush method create a new WriteWorker, as this is the only place we create it in the code 5) The WriteWorker is started, calls flushWrites() 6) When this methods returns, the WriteMonitor wait for notification 7) As soon as the SerialIoProcessor.remove() method will be called, the flush(à method will be called and it will notify the WriteMonitor, releasing the thread, if it were blocked on a wait(). The remove() is invoked when the session is closed. I don't have the code of your application, so I can't tell if you close the session, and when. Also there is something strange I see in the traces : if you check the thread 30, you can see that the SerialSessionImpl.flushWrites() method is called, and end with a call to PdrProtocolEngine.messageSent() method, which does not return. I'm wondering if this method is not supposed to timeout at some point, and then close the session, if it can't write to the client. This is a bit difficult to say what'ss really going in in your app, as I don't see the code, so consider those elements as semi blind guesses ... > Unbound thread growth on discovery attempts > ------------------------------------------- > > Key: DIRMINA-708 > URL: https://issues.apache.org/jira/browse/DIRMINA-708 > Project: MINA > Issue Type: Bug > Reporter: boB Gage > Attachments: profile-mina.txt.gz > > > Using several different possible protocol handlers (handler, codecs, et al) > on several potential ports (serial and/or network), our code attempts to > discover devices on the far end and attach the proper decoders on the proper > ports. > Generally, this process is working, however, every failed discovery attempt > has launched roughly 6 threads, but only destroyed roughly 4 of them. The > 2 delta threads sit in WAIT states forever. > More details are available in the "Unbound thread growth" thread of the > listserv. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.