From 00d878aff8a0d4552fcf8347de76c89628a427e6 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 10 Oct 2001 22:14:06 +0000 Subject: [PATCH] supress shutdown when a circuit times out while connecting --- src/ca/tcpiiu.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ca/tcpiiu.cpp b/src/ca/tcpiiu.cpp index 9ad5a8334..11d4c2213 100644 --- a/src/ca/tcpiiu.cpp +++ b/src/ca/tcpiiu.cpp @@ -570,6 +570,7 @@ void tcpiiu::cleanShutdown () void tcpiiu::shutdown ( bool discardPendingMessages ) { if ( ! this->sockCloseCompleted ) { + iiu_conn_state oldState = this->state; this->state = iiu_disconnected; this->sockCloseCompleted = true; @@ -590,17 +591,19 @@ void tcpiiu::shutdown ( bool discardPendingMessages ) } // linux threads in recv() dont wakeup unless we also // call shutdown ( close() by itself is not enough ) - int status = ::shutdown ( this->sock, SD_BOTH ); - if ( status ) { - errlogPrintf ("CAC TCP socket shutdown error was %s\n", - SOCKERRSTR (SOCKERRNO) ); + if ( oldState == iiu_connected ) { + int status = ::shutdown ( this->sock, SD_BOTH ); + if ( status ) { + errlogPrintf ("CAC TCP socket shutdown error was %s\n", + SOCKERRSTR (SOCKERRNO) ); + } } // // on winsock and probably vxWorks shutdown() does not // unblock a thread in recv() so we use close() and introduce // some complexity because we must unregister the fd early // - status = socket_close ( this->sock ); + int status = socket_close ( this->sock ); if ( status ) { errlogPrintf ("CAC TCP socket close error was %s\n", SOCKERRSTR (SOCKERRNO) );