Last snapshot question

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
oshura
Posts: 2
Joined: Thu, 2009-11-05, 12:08

Last snapshot question

#1 Post by oshura »

Hello, I want to ask, if someone knows, if last dicom toolkit snapshot has "dicomnet" module thread safe.

Thanks.

Shaeto
Posts: 147
Joined: Tue, 2009-01-20, 17:50
Location: CA, USA
Contact:

#2 Post by Shaeto »

per developers it is not thread safe because of gethostbyname/gethostbyaddr but, it is easy to change to getaddrinfo.

i have good experience with dcmnet in big multithread application.

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

#3 Post by Michael Onken »

Hi Shaeto,

that's interesting information also for the OFFIS DICOM Team - are there any other changes you made for running dcmnet threadsafe? Also, any outstanding threading issues you did not solve so far?

Regards and thanks,
Michael

Shaeto
Posts: 147
Joined: Tue, 2009-01-20, 17:50
Location: CA, USA
Contact:

#4 Post by Shaeto »

no, nothing special for dcmnet.

the application is built on base dcmtk/ofstd libs, so, as i can remember I changed mutexes initialization to allow "recursive" mode, it is important in some applications.

think it is better to add "be recursive" as option for OFMutex but, it is okay for me as is :)

and i didn't solve this problem for solaris mutexes :( sol 8/10 threads libs are very different.

dcmtk (lib) is working very good in heavy loaded multi-thread network application, i didn't manage to find any memory leak (except socket leak i reported before) during weeks of stable running.

I think there are some issues with global objects like dictionary, if someone will try to change/use it from different threads.

diff -ru dcmtk-3.5.5_20090818/ofstd/libsrc/ofthread.cc dcmtk-3.5.5_20090818_local/ofstd/libsrc/ofthread.cc
--- dcmtk-3.5.5_20090818/ofstd/libsrc/ofthread.cc 2005-12-08 18:49:02.000000000 +0300
+++ dcmtk-3.5.5_20090818_local/ofstd/libsrc/ofthread.cc 2009-11-02 23:37:13.000000000 +0300
@@ -551,16 +551,22 @@
#ifdef WINDOWS_INTERFACE
theMutex = (void *)(CreateMutex(NULL, FALSE, NULL));
#elif defined(POSIX_INTERFACE)
+ pthread_mutexattr_t _attr;
+
+ pthread_mutexattr_init(&_attr);
+ pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE);
+
pthread_mutex_t *mtx = new pthread_mutex_t;
if (mtx)
{
- if (pthread_mutex_init(mtx, NULL)) delete mtx;
+ if (pthread_mutex_init(mtx, &_attr)) delete mtx;
else theMutex = mtx;
}
#elif defined(SOLARIS_INTERFACE)
mutex_t *mtx = new mutex_t;
if (mtx)
{
+ #pragma message("TODO: we need recursive mutexes for Solaris!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
if (mutex_init(mtx, USYNC_THREAD, NULL)) delete mtx;
else theMutex = mtx;
}

Shaeto
Posts: 147
Joined: Tue, 2009-01-20, 17:50
Location: CA, USA
Contact:

#5 Post by Shaeto »

just to remember one ticket for dcmnet, i am not sure if you fixed it (i really think it is a bug)

viewtopic.php?t=2159

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

#6 Post by Michael Onken »

Hi,

thanks for the hints regarding the threading.

I had a look into the dulconst.cc code you posted in the other thread (it's still on our internal TODO list) and I'm 99% sure you're right. However, it would be good to test that code -- actually it was never really tested as far as i know because the role selection feature is not needed for most of the DICOM services. The dcmqrdb tool (our mini pacs) should be able to support C-GET (which needs that feature) as an option to the standard C-MOVE, however I have to look after a C-GET client SCU tool for this ;)

Regards,
Michael

oshura
Posts: 2
Joined: Thu, 2009-11-05, 12:08

#7 Post by oshura »

I will try dcmtk-dcmnet using multithread. I need to change a comercial api with dcmtk. Each change I make will be reported to you. But first of all I need to patch the actual version to have no pressure over this change and get familiar with offis library.

Thanks to all.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest