diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp index b8e15e4..129a804 100644 --- a/cpp/src/Ice/Selector.cpp +++ b/cpp/src/Ice/Selector.cpp @@ -98,11 +98,11 @@ Selector::finish(EventHandler* handler) } EventHandler* -Selector::getNextHandler(SocketOperation& status, int timeout) +Selector::getNextHandler(SocketOperation& status, DWORD& count, int& error, int timeout) { ULONG_PTR key; LPOVERLAPPED ol; - DWORD count; + error = 0; if(!GetQueuedCompletionStatus(_handle, &count, &key, &ol, timeout > 0 ? timeout * 1000 : INFINITE)) { @@ -130,8 +130,8 @@ Selector::getNextHandler(SocketOperation& status, int timeout) AsyncInfo* info = static_cast(ol); #endif status = info->status; - info->count = SOCKET_ERROR; - info->error = WSAGetLastError(); + count = SOCKET_ERROR; + error = WSAGetLastError(); return reinterpret_cast(key); } @@ -142,8 +142,6 @@ Selector::getNextHandler(SocketOperation& status, int timeout) AsyncInfo* info = static_cast(ol); #endif status = info->status; - info->count = count; - info->error = 0; return reinterpret_cast(key); } diff --git a/cpp/src/Ice/Selector.h b/cpp/src/Ice/Selector.h index 7204b28..5a61231 100644 --- a/cpp/src/Ice/Selector.h +++ b/cpp/src/Ice/Selector.h @@ -52,7 +52,7 @@ public: void update(EventHandler*, SocketOperation, SocketOperation); void finish(EventHandler*); - EventHandler* getNextHandler(SocketOperation&, int); + EventHandler* getNextHandler(SocketOperation&, DWORD&, int&, int); HANDLE getIOCPHandle() { return _handle; } diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 1f9a334..05677a9 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -753,7 +753,8 @@ IceInternal::ThreadPool::run(const IceUtil::ThreadPtr& thread) try { current._ioCompleted = false; - current._handler = _selector.getNextHandler(current.operation, _threadIdleTime); + current._handler = _selector.getNextHandler(current.operation, current._count, current._error, + _threadIdleTime); } catch(const SelectorTimeoutException&) { @@ -797,7 +798,8 @@ IceInternal::ThreadPool::run(const IceUtil::ThreadPtr& thread) try { - current._handler = _selector.getNextHandler(current.operation, _serverIdleTime); + current._handler = _selector.getNextHandler(current.operation, current._count, current._error, + _serverIdleTime); } catch(const SelectorTimeoutException&) { @@ -926,6 +928,11 @@ IceInternal::ThreadPool::startMessage(ThreadPoolCurrent& current) assert(!(current._handler->_ready & current.operation)); current._handler->_ready = static_cast(current._handler->_ready | current.operation); current._handler->_started = static_cast(current._handler->_started & ~current.operation); + + NativeInfoPtr info = current._handler->getNativeInfo(); + info->count = current._count; + info->error = current._error; + if(!current._handler->finishAsync(current.operation)) // Returns false if the handler is finished. { current._handler->_pending = static_cast(current._handler->_pending & ~current.operation); diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index 8a81edf..419fb0f 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -152,6 +152,9 @@ private: bool _ioCompleted; #ifndef ICE_USE_IOCP bool _leader; +#else + DWORD _count; + int _error; #endif friend class ThreadPool; };