Stop the listening thread by using the DcmStorageSCP class

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
liuxinming
Posts: 83
Joined: Thu, 2009-03-19, 04:19

Stop the listening thread by using the DcmStorageSCP class

#1 Post by liuxinming »

Hi everyone,

There is a method called listen in the DcmStorageSCP class. If I call the method in my own sub thread and want to PROPERLY shut down the listening thread, how should I do? At least I can't find any related methods in this class. In fact, when mannually shutting down the thread, memory leaks will be caused.

Thanks for advance!

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

Re: Stop the listening thread by using the DcmStorageSCP cla

#2 Post by J. Riesmeier »

The base class DcmSCP provides a method for this purpose: DcmSCP::stopAfterCurrentAssociation()

liuxinming
Posts: 83
Joined: Thu, 2009-03-19, 04:19

Re: Stop the listening thread by using the DcmStorageSCP cla

#3 Post by liuxinming »

J. Riesmeier wrote:The base class DcmSCP provides a method for this purpose: DcmSCP::stopAfterCurrentAssociation()
Yes, I' ve check the codes in scp.cc, and I found that if the value returned by this function is False, there will be a infinite loop for listening. But if I want to manually terminate the loop, how do the network resources have to be released? In other words, sometimes I want to release the memory first and then drop the network.

For instance, the method listen is called in the sub thread named ListenThread which being made by myself, and when I terminate the thread, the listening process also being terminate, the memory leaks appear. (BTW, I use VC2010 and the object dumping is listed in the output window.)

If stopAfterCurrentAssociation return true, it will never step into the loop. As the listening process has already been started, it has to wait for some associations coming, or else stopAfterCurrentAssociation will never be called. If I want to terminate the loop immediately without waiting for associations, will waitForAssociation properly drop the network?

Sincerely!
Last edited by liuxinming on Wed, 2014-07-02, 05:55, edited 1 time in total.

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

Re: Stop the listening thread by using the DcmStorageSCP cla

#4 Post by J. Riesmeier »

Did you already check the threaded version of the DcmSCP (i.e. DcmSCPPool and associated classes)?

If stopAfterCurrentAssociation() does not meet your requirements, you should consider to overwrite further methods in your derived class, e.g. listen() or waitForAssociationRQ().

Post Reply

Who is online

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