diff options
author | Benoit Foucher <benoit@zeroc.com> | 2018-11-15 08:24:20 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2018-11-15 08:24:20 +0100 |
commit | 1ced32aaad9731c1fc14e232dc6463159b3d48d5 (patch) | |
tree | 6cafbc5c62c564dfe7a0d27c2f6254c3485c2264 /cpp/src | |
parent | Set slice output to avoid warning with Android Studio (diff) | |
download | ice-1ced32aaad9731c1fc14e232dc6463159b3d48d5.tar.bz2 ice-1ced32aaad9731c1fc14e232dc6463159b3d48d5.tar.xz ice-1ced32aaad9731c1fc14e232dc6463159b3d48d5.zip |
Fixed SOCKET_ERROR assignement with DWORD, fixes #267
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Ice/Network.cpp | 11 | ||||
-rwxr-xr-x | cpp/src/Ice/Network.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Selector.cpp | 4 | ||||
-rwxr-xr-x | cpp/src/Ice/StreamSocket.cpp | 12 | ||||
-rwxr-xr-x | cpp/src/Ice/TcpAcceptor.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 6 | ||||
-rwxr-xr-x | cpp/src/Ice/UdpTransceiver.cpp | 27 | ||||
-rw-r--r-- | cpp/src/IceSSL/UWPTransceiverI.cpp | 8 |
8 files changed, 41 insertions, 32 deletions
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index e9ddd8b1f5e..f14ddabdc3d 100755 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -910,6 +910,7 @@ IceInternal::NativeInfo::queueAction(SocketOperation op, IAsyncAction^ action, b if(checkIfErrorOrCompleted(op, action, action->Status, connect)) { asyncInfo->count = 0; + asyncInfo->error = ERROR_SUCCESS; } else { @@ -933,13 +934,13 @@ IceInternal::NativeInfo::queueActionCompleted(SocketOperation op, AsyncInfo* asy { if(status != Windows::Foundation::AsyncStatus::Completed) { - asyncInfo->count = SOCKET_ERROR; asyncInfo->error = info->ErrorCode.Value; } else { - asyncInfo->count = 0; + asyncInfo->error = ERROR_SUCCESS; } + asyncInfo->count = 0; completed(op); } @@ -958,6 +959,7 @@ IceInternal::NativeInfo::queueOperation(SocketOperation op, IAsyncOperation<unsi // the AsyncInfo structure after calling the completed callback. // info->count = static_cast<int>(operation->GetResults()); + info->error = ERROR_SUCCESS; _completedHandler(op); return; } @@ -988,12 +990,13 @@ IceInternal::NativeInfo::queueOperationCompleted(SocketOperation op, AsyncInfo* { if(status != Windows::Foundation::AsyncStatus::Completed) { - info->count = SOCKET_ERROR; + info->count = 0; info->error = operation->ErrorCode.Value; } else { info->count = static_cast<int>(operation->GetResults()); + info->error = ERROR_SUCCESS; } completed(op); } @@ -3036,7 +3039,7 @@ IceInternal::doFinishConnectAsync(SOCKET fd, AsyncInfo& info) // failure to connect. The socket isn't closed by this method. // - if(static_cast<int>(info.count) == SOCKET_ERROR) + if(info.error != ERROR_SUCCESS) { WSASetLastError(info.error); if(connectionRefused()) diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index d0ea1474f7d..21a13c0f5c2 100755 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -164,7 +164,7 @@ struct ICE_API AsyncInfo : WSAOVERLAPPED WSABUF buf; DWORD flags; DWORD count; - int error; + DWORD error; }; #elif defined(ICE_OS_UWP) struct ICE_API AsyncInfo diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp index d79db112b15..585c3b717df 100644 --- a/cpp/src/Ice/Selector.cpp +++ b/cpp/src/Ice/Selector.cpp @@ -153,7 +153,7 @@ Selector::getNextHandler(SocketOperation& status, int timeout) #ifdef ICE_USE_IOCP ULONG_PTR key; LPOVERLAPPED ol; - error = 0; + error = ERROR_SUCCESS; if(!GetQueuedCompletionStatus(_handle, &count, &key, &ol, timeout > 0 ? timeout * 1000 : INFINITE)) { @@ -177,7 +177,7 @@ Selector::getNextHandler(SocketOperation& status, int timeout) { status = info->status; } - count = static_cast<DWORD>(SOCKET_ERROR); + count = 0; error = WSAGetLastError(); return reinterpret_cast<EventHandler*>(key); } diff --git a/cpp/src/Ice/StreamSocket.cpp b/cpp/src/Ice/StreamSocket.cpp index 6067670d20d..a39d0c4ae66 100755 --- a/cpp/src/Ice/StreamSocket.cpp +++ b/cpp/src/Ice/StreamSocket.cpp @@ -92,7 +92,7 @@ StreamSocket::connect(Buffer& readBuffer, Buffer& writeBuffer) #if defined(ICE_USE_IOCP) doFinishConnectAsync(_fd, _write); #elif defined(ICE_OS_UWP) - if(_write.count == SOCKET_ERROR) + if(_write.error != ERROR_SUCCESS) { try { @@ -389,6 +389,7 @@ StreamSocket::startWrite(Buffer& buf) _write.buf.len = static_cast<DWORD>(packetSize); _write.buf.buf = reinterpret_cast<char*>(&*buf.i); + _write.error = ERROR_SUCCESS; int err = WSASend(_fd, &_write.buf, 1, &_write.count, 0, &_write, ICE_NULLPTR); if(err == SOCKET_ERROR) { @@ -415,7 +416,7 @@ StreamSocket::finishWrite(Buffer& buf) return; } - if(static_cast<int>(_write.count) == SOCKET_ERROR) + if(_write.error != ERROR_SUCCESS) { WSASetLastError(_write.error); if(connectionLost()) @@ -444,6 +445,7 @@ StreamSocket::startRead(Buffer& buf) size_t packetSize = getRecvPacketSize(length); _read.buf.len = static_cast<DWORD>(packetSize); _read.buf.buf = reinterpret_cast<char*>(&*buf.i); + _read.error = ERROR_SUCCESS; int err = WSARecv(_fd, &_read.buf, 1, &_read.count, &_read.flags, &_read, ICE_NULLPTR); if(err == SOCKET_ERROR) { @@ -469,7 +471,7 @@ StreamSocket::finishRead(Buffer& buf) return; } - if(static_cast<int>(_read.count) == SOCKET_ERROR) + if(_read.error != ERROR_SUCCESS) { WSASetLastError(_read.error); if(connectionLost()) @@ -554,7 +556,7 @@ StreamSocket::finishWrite(Buffer& buf) return; } - if(_write.count == SOCKET_ERROR) + if(_write.error != ERROR_SUCCESS) { checkErrorCode(__FILE__, __LINE__, _write.error); } @@ -586,7 +588,7 @@ StreamSocket::finishRead(Buffer& buf) return; } - if(_read.count == SOCKET_ERROR) + if(_read.error != ERROR_SUCCESS) { checkErrorCode(__FILE__, __LINE__, _read.error); } diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp index 4dfcb427e42..e0a6f053318 100755 --- a/cpp/src/Ice/TcpAcceptor.cpp +++ b/cpp/src/Ice/TcpAcceptor.cpp @@ -131,6 +131,7 @@ IceInternal::TcpAcceptor::startAccept() assert(_acceptFd == INVALID_SOCKET); _acceptFd = createSocket(false, _addr); const int sz = static_cast<int>(_acceptBuf.size() / 2); + _info.error = ERROR_SUCCESS; if(!AcceptEx(_fd, _acceptFd, &_acceptBuf[0], 0, sz, sz, &_info.count, &_info)) { if(!wouldBlock()) @@ -143,7 +144,7 @@ IceInternal::TcpAcceptor::startAccept() void IceInternal::TcpAcceptor::finishAccept() { - if(static_cast<int>(_info.count) == SOCKET_ERROR || _fd == INVALID_SOCKET) + if(_info.error != ERROR_SUCCESS || _fd == INVALID_SOCKET) { closeSocketNoThrow(_acceptFd); _acceptFd = INVALID_SOCKET; diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index dc965a78033..cc70d9c2033 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -765,8 +765,8 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread) #ifdef ICE_OS_UWP current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, _threadIdleTime)); #else - current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, current._count, current._error, - _threadIdleTime)); + current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, current._count, + current._error, _threadIdleTime)); #endif } catch(const SelectorTimeoutException&) @@ -817,7 +817,7 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread) #else current._handler = ICE_GET_SHARED_FROM_THIS(_selector.getNextHandler(current.operation, current._count, - current._error, _serverIdleTime)); + current._error, _serverIdleTime)); #endif } catch(const SelectorTimeoutException&) diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 49f60a06f80..4d1a9617ca6 100755 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -75,7 +75,7 @@ IceInternal::UdpTransceiver::initialize(Buffer& /*readBuffer*/, Buffer& /*writeB #if defined(ICE_USE_IOCP) doFinishConnectAsync(_fd, _write); #elif defined(ICE_OS_UWP) - if(_write.count == SOCKET_ERROR) + if(_write.error != ERROR_SUCCESS) { try { @@ -387,6 +387,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) else { _write.count = 0; + _write.error = ERROR_SUCCESS; _writer = ref new DataWriter(safe_cast<DatagramSocket^>(_fd)->OutputStream); } } @@ -409,6 +410,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) else { _write.count = 0; + _write.error = ERROR_SUCCESS; _writer = ref new DataWriter(operation->GetResults()); if(_mcastAddr.host != nullptr) { @@ -461,6 +463,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) #else _write.buf.len = static_cast<int>(buf.b.size()); _write.buf.buf = reinterpret_cast<char*>(&*buf.i); + _write.error = ERROR_SUCCESS; int err; if(_state == StateConnected) { @@ -482,8 +485,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) // No peer has sent a datagram yet. throw SocketException(__FILE__, __LINE__, 0); } - err = WSASendTo(_fd, &_write.buf, 1, &_write.count, 0, &_peerAddr.sa, - len, &_write, ICE_NULLPTR); + err = WSASendTo(_fd, &_write.buf, 1, &_write.count, 0, &_peerAddr.sa, len, &_write, ICE_NULLPTR); } if(err == SOCKET_ERROR) @@ -511,14 +513,14 @@ IceInternal::UdpTransceiver::connectCompleted(Windows::Foundation::IAsyncAction^ { if(status != Windows::Foundation::AsyncStatus::Completed) { - _write.count = SOCKET_ERROR; _write.error = action->ErrorCode.Value; } else { - _write.count = 0; + _write.error = ERROR_SUCCESS; _writer = ref new DataWriter(safe_cast<DatagramSocket^>(_fd)->OutputStream); } + _write.count = 0; completed(SocketOperationConnect); } @@ -528,14 +530,14 @@ IceInternal::UdpTransceiver::getOutputStreamMcastCompleted(IAsyncOperation<IOutp { if(status != Windows::Foundation::AsyncStatus::Completed) { - _write.count = SOCKET_ERROR; _write.error = operation->ErrorCode.Value; } else { - _write.count = 0; + _write.error = ERROR_SUCCESS; _writer = ref new DataWriter(operation->GetResults()); } + _write.count = 0; if(_mcastAddr.host != nullptr) { setMcastGroup(_fd, _mcastAddr, ""); @@ -555,7 +557,7 @@ IceInternal::UdpTransceiver::getOutputStreamCompleted(concurrency::task<IOutputS } catch(Platform::Exception^ pex) { - _write.count = SOCKET_ERROR; + _write.count = 0; _write.error = pex->HResult; completed(SocketOperationWrite); } @@ -571,7 +573,7 @@ IceInternal::UdpTransceiver::finishWrite(Buffer& buf) return; } - if(static_cast<int>(_write.count) == SOCKET_ERROR) + if(_write.error != ERROR_SUCCESS) { #ifndef ICE_OS_UWP WSASetLastError(_write.error); @@ -602,6 +604,7 @@ IceInternal::UdpTransceiver::startRead(Buffer& buf) #ifndef ICE_OS_UWP _read.buf.len = packetSize; _read.buf.buf = reinterpret_cast<char*>(&*buf.i); + _read.error = ERROR_SUCCESS; int err; if(_state == StateConnected) { @@ -612,8 +615,8 @@ IceInternal::UdpTransceiver::startRead(Buffer& buf) memset(&_readAddr.saStorage, 0, sizeof(struct sockaddr_storage)); _readAddrLen = static_cast<socklen_t>(sizeof(sockaddr_storage)); - err = WSARecvFrom(_fd, &_read.buf, 1, &_read.count, &_read.flags, - &_readAddr.sa, &_readAddrLen, &_read, ICE_NULLPTR); + err = WSARecvFrom(_fd, &_read.buf, 1, &_read.count, &_read.flags, &_readAddr.sa, &_readAddrLen, &_read, + ICE_NULLPTR); } if(err == SOCKET_ERROR) @@ -683,7 +686,7 @@ IceInternal::UdpTransceiver::finishRead(Buffer& buf) checkErrorCode(__FILE__, __LINE__, ex->HResult); } #else - if(static_cast<int>(_read.count) == SOCKET_ERROR) + if(_read.error != ERROR_SUCCESS) { WSASetLastError(_read.error); diff --git a/cpp/src/IceSSL/UWPTransceiverI.cpp b/cpp/src/IceSSL/UWPTransceiverI.cpp index 2afd9ad0e59..e357f284cc3 100644 --- a/cpp/src/IceSSL/UWPTransceiverI.cpp +++ b/cpp/src/IceSSL/UWPTransceiverI.cpp @@ -289,7 +289,7 @@ UWP::TransceiverI::finishWrite(IceInternal::Buffer& buf) if(_connected && !_upgraded) { IceInternal::AsyncInfo* asyncInfo = getNativeInfo()->getAsyncInfo(IceInternal::SocketOperationWrite); - if(asyncInfo->count == SOCKET_ERROR) + if(asyncInfo->error != ERROR_SUCCESS) { if(CERT_E_CN_NO_MATCH == asyncInfo->error) { @@ -368,9 +368,9 @@ UWP::TransceiverI::setBufferSize(int rcvSize, int sndSize) } UWP::TransceiverI::TransceiverI(const InstancePtr& instance, - const IceInternal::TransceiverPtr& delegate, - const string& hostOrAdapterName, - bool incoming) : + const IceInternal::TransceiverPtr& delegate, + const string& hostOrAdapterName, + bool incoming) : _instance(instance), _engine(UWP::SSLEnginePtr::dynamicCast(instance->engine())), _host(incoming ? "" : hostOrAdapterName), |