From 1bd0e8b5a785213c21b2207450759d74201c83dd Mon Sep 17 00:00:00 2001 From: 100029962 Date: Mon, 17 Apr 2023 10:06:26 +0200 Subject: [PATCH] [dcmnet] Extend DcmSCU::negotiateAssociation to take a cancel token as argument We'll use this cancel token to cancel ongoing TCP connect attempts. A cancel token allows the client to decide how a request should be cancelled, for example using std::stop_token in the implementation of the ICancelToken. --- dcmnet/include/dcmtk/dcmnet/scu.h | 9 ++++++++- dcmnet/libsrc/scu.cc | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dcmnet/include/dcmtk/dcmnet/scu.h b/dcmnet/include/dcmtk/dcmnet/scu.h index 8c0a14259d..9620c3c925 100644 --- a/dcmnet/include/dcmtk/dcmnet/scu.h +++ b/dcmnet/include/dcmtk/dcmnet/scu.h @@ -185,6 +185,13 @@ class DCMTK_DCMNET_EXPORT RetrieveResponse : public QRResponse RetrieveResponse& operator=(const RetrieveResponse& other); }; +class IDcmCancelToken +{ +public: + virtual ~IDcmCancelToken() {} + virtual bool IsCanceled() const = 0; +}; + /** Base class for implementing DICOM Service Class User functionality. The class offers * support for negotiating associations and sending and receiving arbitrary DIMSE messages * on that connection. DcmSCU has built-in C-ECHO support so derived classes do not have to @@ -226,7 +233,7 @@ class DCMTK_DCMNET_EXPORT DcmSCU * @return EC_Normal if negotiation was successful, otherwise error code. * NET_EC_AlreadyConnected if SCU is already connected. */ - virtual OFCondition negotiateAssociation(); + virtual OFCondition negotiateAssociation(IDcmCancelToken* tcpCancelToken = NULL); /** After negotiation association, this call returns the first usable presentation context * given the desired abstract syntax and transfer syntax diff --git a/dcmnet/libsrc/scu.cc b/dcmnet/libsrc/scu.cc index 9a0c74ed67..0d66d50cce 100644 --- a/dcmnet/libsrc/scu.cc +++ b/dcmnet/libsrc/scu.cc @@ -259,7 +259,7 @@ OFCondition DcmSCU::initNetwork() return cond; } -OFCondition DcmSCU::negotiateAssociation() +OFCondition DcmSCU::negotiateAssociation(IDcmCancelToken* tcpCancelToken) { /* Return error if SCU is already connected */ if (isConnected())