Abort/Cancel sendSTORERequest

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
andeas.henn
Posts: 3
Joined: Tue, 2016-01-05, 15:18

Abort/Cancel sendSTORERequest

#1 Post by andeas.henn »

Hello,

we are currently tying to use

Code: Select all

DcmSCU::sendSTORERequest
concurrently to the main thread in an extra thread to export images and videos. Everything works just great and in between different files we check if user wishes to cancel the export process. BUT if a file is rather big and network transfer rate is slow, then the occasions to cancel the process are too seldom. How can one abort or even better cancel the transfer (preferably gracefully/"polite")?

I tried to look inside the depth of DcmSCU::sendStoreRequest (down to sendDcmDataset) in hopes to find a condition variable, callback or something like that, that could be used to cancel/stop the actual sending loop but did not find anything that could help. I hoped, that there is something compareable to 'handleCGETResponse' à la 'handleSTOREResponse' or that I could use 'callbackSENDProgress' to check if process should be cancelled and somehow indicate this wish to DCMTK. There are some checks and I thought about to provoke some kind of error, so that one of those checks would cancel the sending process. I would not mind if the abort would not be polite, just without segfaults and memory leaks. Did I miss something?

Can one use/invoke

Code: Select all

DcmSCU::closeAssociation, DcmSCU::releaseAssociation or DcmSCU::abortAssociation
from while sendDcmDataset is running in another thread?

Any help is much appriciated!!

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Abort/Cancel sendSTORERequest

#2 Post by J. Riesmeier »

Everything works just great and in between different files we check if user wishes to cancel the export process. BUT if a file is rather big and network transfer rate is slow, then the occasions to cancel the process are too seldom. How can one abort or even better cancel the transfer (preferably gracefully/"polite")?

I tried to look inside the depth of DcmSCU::sendStoreRequest (down to sendDcmDataset) in hopes to find a condition variable, callback or something like that, that could be used to cancel/stop the actual sending loop but did not find anything that could help.
Some time ago, I also checked the DcmSCU (and underlying "dcmnet" functions) for a mechanism that would allow one to "abort" a running C-STORE request. The result of my investigations was that there does not seem to be one. The reason is probably that the core "dcmnet" functions are more than 20 years old and at that time DICOM objects were pretty small, so nobody thought about such a need.

Actually, I considered adding such a mechanism to "dcmnet", but since I didn't needed it for my customer project I postponed this idea. So, if you've got a proposal, you are free to contribute your enhancements to the Open Source DICOM toolkit DCMTK :) Here's some background information on "How new features are added to the DCMTK".

andeas.henn
Posts: 3
Joined: Tue, 2016-01-05, 15:18

Re: Abort/Cancel sendSTORERequest

#3 Post by andeas.henn »

Thank you for your fast replly! I would very much like to contribute to an open source project, especially to DCMTK, since it serves a very important purpose. If I come up with a solution, I will gladly contribute it.

Can you think of some tips or hints for me? E.g. Which approach is in your opnion the most promising one or which pitfalls I should avoid? Anything?

andeas.henn
Posts: 3
Joined: Tue, 2016-01-05, 15:18

Re: Abort/Cancel sendSTORERequest

#4 Post by andeas.henn »

Update: As you can imagine I tried first the approach without changing any code of DCMTK. And the following:
andeas.henn wrote: Can one use/invoke

Code: Select all

DcmSCU::closeAssociation, DcmSCU::releaseAssociation or DcmSCU::abortAssociation
from while sendDcmDataset is running in another thread?
does seem to work.

Of course all kinds of errors are indicated:
  • Error: store result: 0: 526, DIMSE Failed to send message
  • 0006:031d TCP I/O Error (No error) occurred in routine: writeDataPDU
  • Failed sending C-STORE request: 0006:020e DIMSE Failed to send message
  • No data to commit
  • ...
, but the export is cancelled and all ressources seem to be freed.

So a propper solution is still aimed for. The most scary part for me in the depth of DCMTK is currently a state machine :shock: which seems to handle the network interaction: do I need to touch this to add cancellability :? ?

EDIT: typo
Last edited by andeas.henn on Fri, 2016-12-02, 14:40, edited 1 time in total.

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Abort/Cancel sendSTORERequest

#5 Post by Michael Onken »

Hi,

actually, to be honest: That is the most scary part for us too :) Probably you have to touch it but we also would have to dig into the details to tell you where and how...

Best,
Michael

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Abort/Cancel sendSTORERequest

#6 Post by J. Riesmeier »

I don 't think that you need to touch the state machine. My idea, at that time, was to enhance sendDcmDataset() in "dimse.cc" accordingly. There is a while() loop that iterates over all PDVs of a data or command set... so, your break condition should be checked there.

The easiest way would probably be to add a boolean return value to the (progress) callback function, which can then be used to check whether to exit the while() loop. However, this would not be (API) compatible with previous versions of the DCMTK :?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest