Fixed deadlock in SMPPSession/AbstractSession close methods #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am using the jsmpp API to listen for incoming SMS messages on a socket connection.
In average this socket connection stopped every 24 hours. I could also make it stop by breaking the network connection between my server and the SMPP Gateway.
I turned out that it was a deadlock caused by the EnquireLinkSender thread waiting for the PDUReader thread and visa versa.
This pull request moves all cleanup code into the superclass (AbstractSession) and I have added a check for which thread is calling the close method.
After running with this patch the SMPP API is able to close properly without any deadlock.
I have added a watchdog in my code outside the SMPP API that reconnects the SMPP Session when this happens instead of making the jsmpp API handle this and restart itself.