I ran some stress tests to verify the behavior of my DICOM SCP component when dealing will parallel associations. Here are the results:
1. If the sender errors out or does not release the association, then the scp will continue to treat this association as active. This means one less parallel association. Eventually, it is possible to fill the active associations list in AE class with "dead" associations and deny service to new valid association requests. Also, the number of threads will be high in such a scenario.
So what I need is the association to self-destruct after a (configurable) period of inactivity. I made some changes to implement this feature and I have attached the diff file to this post. Please review and let me know your thoughts. I also have the unit test for it and I can provide that if you agree with my changes.
2. The ARTIMER is working correctly, however the threads (association and DULServiceProvider) were still hanging around after the client connection was closed. So, I introduced code to kill the DULServiceProvider loop if CheckTimer() is True and in the Association class I terminate the thread if self.DUL is not running anymore. The DULServiceProvider code is not in the diff file. I added the following line to run() in my copy of DULServiceProvider.py:
elif CheckTimer()
self.kill = True
This causes the DULServiceProvider thread to terminate but the Association thread continues to run (despite my attempt to terminate it when self.DUL.isAlive() returns False, see diff file). I am investigating that problem, but in the meantime I would like to get your feedback on the association idle timeout feature.
3. The removal of completed associations from the active associations list in AE class is happening during iteration, which will cause items to be skipped. Try this instead:
self.Associations[:] = [active_assoc for active_assoc in self.Associations if active_assoc.isAlive()]
4. The result source is incorrectly set to 1 in AE_8() in fsm.py. Setting the source when constructing the response and removing the hardcoding fixes this defect.