Graceful termination of DcmSCP::listen()

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Russell
Posts: 7
Joined: Fri, 2016-08-26, 16:07

Graceful termination of DcmSCP::listen()

#1 Post by Russell »

I'm trying to cause a graceful termination of DcmSCP::listen() by overriding and altering the return value of stopAfterCurrentAssociation from somewhere outside. Before I enter listen(), I call setConnectionBlockingMode(DUL_NOBLOCK); setConnectionTimeout(2); This causes

Code: Select all

  while( cond.good() && !stopAfterCurrentAssociation() )
  {
    cond = waitForAssociationRQ(network);
  }
to loop twice. The first time, waitForAssociationRQ returns EC_Normal, allowing the while to do the second loop. But the second time, waitForAssociationRQ returns getConnectionTimeout, forcing the while to terminate, before I change the return value of stopAfterCurrentAssociation to true. This behavior is not what I want. I was expecting the while to continue indefinitely, while checking
stopAfterCurrentAssociation every 2 seconds. I appreciate if somebody can clarify where my misunderstanding lies.

Russell
Posts: 7
Joined: Fri, 2016-08-26, 16:07

Re: Graceful termination of DcmSCP::listen()

#2 Post by Russell »

I'm all set for now.
I made the below changes near line 1782 of ASC_receiveAssociation() of dcmtk361 to achieve the desired behavior.

Code: Select all

    if (cond.bad()) 
    {
        ASC_destroyAssociationParameters(&params);
        free(*assoc);
        *assoc = NULL;
        return cond;
    }

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

Re: Graceful termination of DcmSCP::listen()

#3 Post by J. Riesmeier »

Line 1782 in which file?

Russell
Posts: 7
Joined: Fri, 2016-08-26, 16:07

Re: Graceful termination of DcmSCP::listen()

#4 Post by Russell »

dcmtk361\dcmnet\libsrc\assoc.cc

Inside ASC_receiveAssociation(), I modified the if (cond.bad()) line that evaluates true when the timer elapses and cond becomes equal to DUL_NOASSOCIATIONREQUEST, which the calling function waitForAssociationRQ treats as a EC_Normal. The special treatment of DUL_NOASSOCIATIONREQUEST made me think the author intended the while loop inside of the listen() to keep looping during a timeout. But the (m_assoc != NULL) was preventing the loop from continuing. So I supplied the missing free.

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

Re: Graceful termination of DcmSCP::listen()

#5 Post by J. Riesmeier »

Sorry for the late feedback. Could you please provide a patch (preferably based on the current development version, see http://git.dcmtk.org/). Line numbers are not very reliable when the version of the corresponding file is unknown. Thank you.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest