diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-03-02 09:17:30 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-03-02 09:17:30 +0000 |
commit | 2f7037965c40f4d68784f51613d5e9b9a395fcaa (patch) | |
tree | f056ed5d9a3e9ed678cc1b43c84e79422307031a /cppe/src | |
parent | windows fixes. (diff) | |
download | ice-2f7037965c40f4d68784f51613d5e9b9a395fcaa.tar.bz2 ice-2f7037965c40f4d68784f51613d5e9b9a395fcaa.tar.xz ice-2f7037965c40f4d68784f51613d5e9b9a395fcaa.zip |
- Fixes for Windows shutdown issue.
- Use a static mutex for the logger.
Diffstat (limited to 'cppe/src')
-rwxr-xr-x | cppe/src/IceE/Connection.cpp | 25 | ||||
-rw-r--r-- | cppe/src/IceE/LoggerI.cpp | 11 | ||||
-rw-r--r-- | cppe/src/IceE/LoggerI.h | 6 | ||||
-rw-r--r-- | cppe/src/TcpTransport/Transceiver.cpp | 4 |
4 files changed, 27 insertions, 19 deletions
diff --git a/cppe/src/IceE/Connection.cpp b/cppe/src/IceE/Connection.cpp index 57058258ff9..746d906cf94 100755 --- a/cppe/src/IceE/Connection.cpp +++ b/cppe/src/IceE/Connection.cpp @@ -135,11 +135,6 @@ Ice::Connection::close(bool force) #endif setState(StateClosing, CloseConnectionException(__FILE__, __LINE__)); - - // - // TODO: If blocking model we should call readStream() to wait for - // the connection closure from the server? - // } } @@ -930,7 +925,15 @@ Ice::Connection::Connection(const InstancePtr& instance, } else { +#ifdef _WIN32 + // + // On Windows, the recv() call doesn't return if the socket is + // shutdown. We use the timeout to not block indefinitely. + // + _transceiver->setTimeouts(_endpoint->timeout(), _endpoint->timeout()); +#else _transceiver->setTimeouts(-1, _endpoint->timeout()); +#endif } #else _transceiver->setTimeouts(_endpoint->timeout(), _endpoint->timeout()); @@ -1321,7 +1324,7 @@ Ice::Connection::setState(State state) _transceiver->shutdownReadWrite(); // - // In blocking mode, we close the transceiver now. + // In blocking mode, we close the transceiver now. // #ifndef ICEE_PURE_BLOCKING_CLIENT if(_blocking) @@ -1625,6 +1628,16 @@ Ice::Connection::run() readStreamAndParseMessage(_stream, requestId); #endif } +#ifdef _WIN32 + catch(const Ice::TimeoutException&) + { + // + // See the comment in the Connection constructor. This is + // necessary to not block in recv() indefinitely. + // + continue; + } +#endif catch(const Ice::LocalException& ex) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); diff --git a/cppe/src/IceE/LoggerI.cpp b/cppe/src/IceE/LoggerI.cpp index 1f34b743adc..c01609b4071 100644 --- a/cppe/src/IceE/LoggerI.cpp +++ b/cppe/src/IceE/LoggerI.cpp @@ -8,12 +8,13 @@ // ********************************************************************** #include <IceE/LoggerI.h> +#include <IceE/StaticMutex.h> using namespace std; using namespace Ice; using namespace IceInternal; -IceUtil::Mutex Ice::LoggerI::_globalMutex; +static IceUtil::StaticMutex globalMutex = ICE_STATIC_MUTEX_INITIALIZER; Ice::LoggerI::LoggerI(const string& prefix) { @@ -26,7 +27,7 @@ Ice::LoggerI::LoggerI(const string& prefix) void Ice::LoggerI::print(const string& message) { - IceUtil::Mutex::Lock sync(_globalMutex); + IceUtil::StaticMutex::Lock sync(globalMutex); fprintf(stderr, "%s\n", message.c_str()); } @@ -34,7 +35,7 @@ Ice::LoggerI::print(const string& message) void Ice::LoggerI::trace(const string& category, const string& message) { - IceUtil::Mutex::Lock sync(_globalMutex); + IceUtil::StaticMutex::Lock sync(globalMutex); string s = "[ "; s += _prefix; @@ -56,13 +57,13 @@ Ice::LoggerI::trace(const string& category, const string& message) void Ice::LoggerI::warning(const string& message) { - IceUtil::Mutex::Lock sync(_globalMutex); + IceUtil::StaticMutex::Lock sync(globalMutex); fprintf(stderr, "%swarning: %s\n", _prefix.c_str(), message.c_str()); } void Ice::LoggerI::error(const string& message) { - IceUtil::Mutex::Lock sync(_globalMutex); + IceUtil::StaticMutex::Lock sync(globalMutex); fprintf(stderr, "%serror: %s\n", _prefix.c_str(), message.c_str()); } diff --git a/cppe/src/IceE/LoggerI.h b/cppe/src/IceE/LoggerI.h index 575706ef4e2..b04c3a2a8ac 100644 --- a/cppe/src/IceE/LoggerI.h +++ b/cppe/src/IceE/LoggerI.h @@ -31,12 +31,6 @@ private: std::string _prefix; std::string _emptyPrefix; - - // - // A global mutex is used to avoid garbled output with multiple - // communicators. - // - static IceUtil::Mutex _globalMutex; }; } diff --git a/cppe/src/TcpTransport/Transceiver.cpp b/cppe/src/TcpTransport/Transceiver.cpp index e464764b487..8ae2022c552 100644 --- a/cppe/src/TcpTransport/Transceiver.cpp +++ b/cppe/src/TcpTransport/Transceiver.cpp @@ -164,13 +164,13 @@ IceInternal::Transceiver::writeWithTimeout(Buffer& buf, int timeout) if(wouldBlock()) { doSelect(false, timeout > 0 ? timeout : _writeTimeout); - continue; + continue; } #endif if(connectionLost()) { - ConnectionLostException ex(__FILE__, __LINE__); + ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); throw ex; } |