Mercurial > hg > freeDiameter
changeset 187:9647d92cf4fb
Add timeout on the socket for clean termination
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 05 Feb 2010 17:22:08 +0900 |
parents | e81a27807172 |
children | 65f5bc7ad0bd |
files | freeDiameter/cnxctx.c |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/freeDiameter/cnxctx.c Thu Feb 04 17:11:19 2010 +0900 +++ b/freeDiameter/cnxctx.c Fri Feb 05 17:22:08 2010 +0900 @@ -1253,6 +1253,15 @@ conn->cc_closing = 1; + /* Set a timeout on the socket so that in any case we are not stuck waiting for something */ + if (conn->cc_socket > 0) { + struct timeval tv; + memset(&tv, 0, sizeof(tv)); + tv.tv_sec = 3; /* 3 seconds timeout */ + CHECK_SYS_DO( setsockopt(conn->cc_socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)), /* best effort only */ ); + CHECK_SYS_DO( setsockopt(conn->cc_socket, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)), /* best effort only */ ); + } + /* Initiate shutdown of the TLS session(s): call gnutls_bye(WR), then read until error */ if (conn->cc_tls) { #ifndef DISABLE_SCTP