First sketch for mechanism to cancel DcmSCU negotiateAssociation before connectionTimeout elapses. #62
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.
If a server is unavailable, the DcmSCU::negotiateAssociation function call will block for the duration of the connectionTimeout. In many cases this timeout may be long, 30-60 seconds to ensure that we can robustly establish associations against slow servers. This is a long time for a user to wait for a device to shut down.
In some use cases, for example for portable imaging devices, the ability to quickly shut down is important to reduce the risk of the user pulling the power cable before the system is completely shut down. Such devices typically have a high risk that servers are temporarily unavailable, for example if they are serving multiple purposes and have to be moved from lab to lab.
The design idea is that the client software can create a socketpair that is used as a communication channel for signalling cancellation. While an association is being established, the client software can send a message on the socket pair from a different thread, which will wake the select in dulfsm.cc requestAssociationTCP function. The error handling will then follow the same path as if the connectionTimeout would be reached.
Another option would be to introduce a 'dcmTcpPollingInterval' and a 'cancelConnection' pointer parameter to the DUL_ASSOCIATESERVICEPARAMETERS structure. We could then set the dcmTcpPollingInterval to for example 5 seconds. In dulfsm.cc requestAssociationTCP, we could then call 'select()' in a loop with the dcmTcpPollingInterval as timeout until we reach the desired connectionTimeout. This would allow us to jump out of the select loop if cancelConnection was set to true in the meantime.
I implemented this on top of #61, which is the first commit.