Bug #618 » socket_timeout_patch_2.diff
| dcmnet/apps/storescp.cc | ||
|---|---|---|
|
#include "dcmtk/dcmdata/dcuid.h" /* for dcmtk version name */
|
||
|
#include "dcmtk/dcmdata/dcdeftag.h"
|
||
|
#include "dcmtk/dcmdata/dcostrmz.h" /* for dcmZlibCompressionLevel */
|
||
|
#include "dcmtk/dcmnet/dcmtrans.h"
|
||
|
#ifdef WITH_OPENSSL
|
||
|
#include "dcmtk/dcmtls/tlstrans.h"
|
||
| ... | ... | |
|
T_DIMSE_BlockingMode opt_blockMode = DIMSE_BLOCKING;
|
||
|
int opt_dimse_timeout = 0;
|
||
|
int opt_acse_timeout = 30;
|
||
|
int opt_socket_timeout = 60;
|
||
|
#if defined(HAVE_FORK) || defined(_WIN32)
|
||
|
OFBool opt_forkMode = OFFalse;
|
||
| ... | ... | |
|
cmd.addOption("--acse-timeout", "-ta", 1, "[s]econds: integer (default: 30)", "timeout for ACSE messages");
|
||
|
cmd.addOption("--dimse-timeout", "-td", 1, "[s]econds: integer (default: unlimited)", "timeout for DIMSE messages");
|
||
|
cmd.addOption("--socket-timeout", "-ts", 1, "[s]econds: integer (default: 60)", "timeout for underlying socket");
|
||
|
OFString opt1 = "set my AE title (default: ";
|
||
|
opt1 += APPLICATIONTITLE;
|
||
| ... | ... | |
|
opt_dimse_timeout = OFstatic_cast(int, opt_timeout);
|
||
|
opt_blockMode = DIMSE_NONBLOCKING;
|
||
|
}
|
||
|
if (cmd.findOption("--socket-timeout"))
|
||
|
{
|
||
|
OFCmdSignedInt opt_timeout = 0;
|
||
|
app.checkValue(cmd.getValueAndCheckMin(opt_timeout, 1));
|
||
|
opt_socket_timeout = OFstatic_cast(int, opt_timeout);
|
||
|
}
|
||
|
if (cmd.findOption("--aetitle")) app.checkValue(cmd.getValue(opt_respondingAETitle));
|
||
|
if (cmd.findOption("--max-pdu")) app.checkValue(cmd.getValueAndCheckMinMax(opt_maxPDU, ASC_MINIMUMPDUSIZE, ASC_MAXIMUMPDUSIZE));
|
||
| ... | ... | |
|
const char* transferSyntaxes[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
|
||
|
int numTransferSyntaxes = 0;
|
||
|
// Set the socket timeout value
|
||
|
DcmTransportConnection::setSocketTimeout(opt_socket_timeout);
|
||
|
// try to receive an association. Here we either want to use blocking or
|
||
|
// non-blocking, depending on if the option --eostudy-timeout is set.
|
||
|
if( opt_endOfStudyTimeout == -1 )
|
||
|
-
|
||
| dcmnet/include/dcmtk/dcmnet/dcmtrans.h | ||
|---|---|---|
|
*/
|
||
|
static OFBool selectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
|
||
|
/** returns the socket timeout value in seconds
|
||
|
* @return socket timeout value
|
||
|
*/
|
||
|
static int getSocketTimeout() { return socketTimeout; }
|
||
|
/** set the socket file descriptor managed by this object.
|
||
|
* @param socket file descriptor
|
||
|
*/
|
||
|
static void setSocketTimeout(int timeout) { socketTimeout = timeout; }
|
||
|
protected:
|
||
|
/** returns the socket file descriptor managed by this object.
|
||
| ... | ... | |
|
*/
|
||
|
static OFBool fastSelectReadableAssociation(DcmTransportConnection *connections[], int connCount, int timeout);
|
||
|
/** Create a class value for how long to hold onto a connection before aborting
|
||
|
*/
|
||
|
static int socketTimeout;
|
||
|
/// the socket file descriptor used by the transport connection.
|
||
|
int theSocket;
|
||
|
};
|
||
| dcmnet/libsrc/dcmtrans.cc | ||
|---|---|---|
|
#include <GUSI.h> /* Use the Grand Unified Sockets Interface (GUSI) on Macintosh */
|
||
|
#endif
|
||
|
int DcmTransportConnection::socketTimeout = 60;
|
||
|
DcmTransportConnection::DcmTransportConnection(int openSocket)
|
||
|
: theSocket(openSocket)
|
||
|
{
|
||
| ... | ... | |
|
{
|
||
|
#ifndef DISABLE_SEND_TIMEOUT
|
||
|
{
|
||
|
/* use a timeout of 60 seconds for the send() function */
|
||
|
const int sendTimeout = 60;
|
||
|
/* set a timeout for the send() function */
|
||
|
const int sendTimeout = DcmTransportConnection::socketTimeout;
|
||
|
DCMNET_DEBUG("setting network send timeout to " << sendTimeout << " seconds");
|
||
|
#ifdef HAVE_WINSOCK_H
|
||
|
// for Windows, specify send timeout in milliseconds
|
||
| ... | ... | |
|
#endif
|
||
|
#ifndef DISABLE_RECV_TIMEOUT
|
||
|
{
|
||
|
/* use a timeout of 60 seconds for the recv() function */
|
||
|
const int recvTimeout = 60;
|
||
|
/* set a timeout for the recv() function */
|
||
|
const int recvTimeout = socketTimeout;
|
||
|
DCMNET_DEBUG("setting network receive timeout to " << recvTimeout << " seconds");
|
||
|
#ifdef HAVE_WINSOCK_H
|
||
|
// for Windows, specify receive timeout in milliseconds
|
||