i didn't find this fix in latest snapshot:
dcmnet/libsrc/dcmtrans.cc
DcmTCPConnection::~DcmTCPConnection()
{
+ close();
}
very bad leak for daemon application
close resources in DcmTCPConnection destructor
Moderator: Moderator Team
forget about ::close - if we'll add close in destructor also need to add those changes:
dcmtrans.h
int getSocket() { return theSocket; }
+ void setSocket(int socket) { theSocket = socket; }
dcmtrans.cc
void DcmTCPConnection::close()
{
+ if (getSocket()>=0) {
#ifdef HAVE_WINSOCK_H
- (void) shutdown(getSocket(), 1 /* SD_SEND */);
- (void) closesocket(getSocket());
+ (void) shutdown(getSocket(), 1 /* SD_SEND */);
+ (void) closesocket(getSocket());
#else
- (void) ::close(getSocket());
+ (void) ::close(getSocket());
#endif
+ setSocket(-1);
+ }
}
dcmtrans.h
int getSocket() { return theSocket; }
+ void setSocket(int socket) { theSocket = socket; }
dcmtrans.cc
void DcmTCPConnection::close()
{
+ if (getSocket()>=0) {
#ifdef HAVE_WINSOCK_H
- (void) shutdown(getSocket(), 1 /* SD_SEND */);
- (void) closesocket(getSocket());
+ (void) shutdown(getSocket(), 1 /* SD_SEND */);
+ (void) closesocket(getSocket());
#else
- (void) ::close(getSocket());
+ (void) ::close(getSocket());
#endif
+ setSocket(-1);
+ }
}
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
I checked the code: the invalidation of the socket variable is only required if the connection object exists after the TCP/IP connection has be closed which is currently not the case (see dul.cc and dulfsm.cc)!
Anyway, setting "theSocket" to "-1" after closing the socket is probably still a good idea
Anyway, setting "theSocket" to "-1" after closing the socket is probably still a good idea
Who is online
Users browsing this forum: No registered users and 1 guest