findscu.exe should return 1 on association failed

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
budric
Posts: 29
Joined: Thu, 2007-06-28, 20:48

findscu.exe should return 1 on association failed

#1 Post by budric »

Hi,

I've checked out latest git branch. If I run findscu and it can't connect to the PACS, the process exits with status 0. I'd like it to exit with 1 indicating there was an error. I would like to submit a simple patch (I hope the diff format is correct, I'm not that good with git):

Code: Select all

diff --git dcmnet/apps/findscu.cc dcmnet/apps/findscu.cc
index a17220f..60fca13 100644
--- dcmnet/apps/findscu.cc
+++ dcmnet/apps/findscu.cc
@@ -627,10 +627,15 @@ int main(int argc, char *argv[])
       NULL, /* we want to use the default callback */
       &fileNameList,
       opt_outputDirectory.c_str());
-
+	if (cond.bad()) return 1;
+	
     // destroy network structure
     cond = findscu.dropNetwork();
-    if (cond.bad()) OFLOG_ERROR(findscuLogger, DimseCondition::dump(temp_str, cond));
+    if (cond.bad()) 
+	{
+		OFLOG_ERROR(findscuLogger, DimseCondition::dump(temp_str, cond));
+		return 1;
+	}
 
 #ifdef HAVE_WINSOCK_H
     WSACleanup();
@@ -644,9 +649,11 @@ int main(int argc, char *argv[])
         if (!tLayer->writeRandomSeed(opt_writeSeedFile))
         {
           OFLOG_ERROR(findscuLogger, "cannot write random seed file '" << opt_writeSeedFile << "', ignoring");
+		  return 1;
         }
       } else {
         OFLOG_ERROR(findscuLogger, "cannot write random seed, ignoring");
+		return 1;
       }
     }
     delete tLayer;
P.S. I had to resort to calling external findscu process to allow multiple queries from different threads in my program at the same time. Are there any plans to make the networking/sockets portion of the code thread safe?

Thank you.

Post Reply

Who is online

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