diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-03-30 12:15:48 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-03-30 12:15:48 -0400 |
commit | c16a3b78c4ad8baded3c99f4d4556befd9eb2eb0 (patch) | |
tree | 71a51d53e47359fd948f6791f3cfb97438b367e1 /util | |
parent | adddf74ca1a379ae94471455a99d7ba67e574a88 (diff) | |
download | mongo-c16a3b78c4ad8baded3c99f4d4556befd9eb2eb0.tar.gz |
cleaner socket timeout logic
Diffstat (limited to 'util')
-rw-r--r-- | util/message.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/util/message.cpp b/util/message.cpp index 37099dcbbc5..d59faaaccc6 100644 --- a/util/message.cpp +++ b/util/message.cpp @@ -544,7 +544,14 @@ again: while( len > 0 ) { int ret = ::send( sock , data , len , portSendFlags ); if ( ret == -1 ) { - if ( errno != EAGAIN || _timeout == 0 ) { + if ( ( errno == EAGAIN || errno == EWOULDBLOCK ) && _timeout != 0 ) { + if ( !serverAlive( farEnd.toString() ) ) { + log(_logLevel) << "MessagingPort " << context << " send() remote dead " << farEnd.toString() << endl; + throw SocketException( SocketException::SEND_ERROR ); + } + // should just retry + } + else { SocketException::Type t = SocketException::SEND_ERROR; #if defined(_WINDOWS) if( e == WSAETIMEDOUT ) t = SocketException::SEND_TIMEOUT; @@ -552,12 +559,6 @@ again: log(_logLevel) << "MessagingPort " << context << " send() " << errnoWithDescription() << ' ' << farEnd.toString() << endl; throw SocketException( t ); } - else { - if ( !serverAlive( farEnd.toString() ) ) { - log(_logLevel) << "MessagingPort " << context << " send() remote dead " << farEnd.toString() << endl; - throw SocketException( SocketException::SEND_ERROR ); - } - } } else { assert( ret <= len ); |