diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Selector.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 22 |
2 files changed, 24 insertions, 7 deletions
diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp index b926ebc4419..e0c228ffcf9 100644 --- a/cpp/src/Ice/Selector.cpp +++ b/cpp/src/Ice/Selector.cpp @@ -72,6 +72,7 @@ Selector::initialize(EventHandler* handler) { return; } + #ifdef ICE_USE_IOCP HANDLE socket = reinterpret_cast<HANDLE>(handler->getNativeInfo()->fd()); if(CreateIoCompletionPort(socket, _handle, reinterpret_cast<ULONG_PTR>(handler), 0) == ICE_NULLPTR) @@ -114,6 +115,14 @@ Selector::update(EventHandler* handler, SocketOperation remove, SocketOperation void Selector::finish(IceInternal::EventHandler* handler) { +#ifdef ICE_OS_UWP + // If async operations are no longer pending, clear the completion handler to break + // the cyclic reference count. + if(!handler->_started) + { + handler->getNativeInfo()->setCompletedHandler(nullptr); + } +#endif handler->_registered = SocketOperationNone; handler->_finish = false; // Ensures that finished() is only called once on the event handler. } diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 9a4a15f6c7e..e1d5165c31f 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -540,10 +540,10 @@ IceInternal::ThreadPool::dispatchFromThisThread(const DispatchWorkItemPtr& workI { #ifdef ICE_CPP11_MAPPING _dispatcher([workItem]() - { - workItem->run(); - }, - workItem->getConnection()); + { + workItem->run(); + }, + workItem->getConnection()); #else _dispatcher->dispatch(workItem, workItem->getConnection()); #endif @@ -702,7 +702,7 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread) // Get the next ready handler. // while(_nextHandler != _handlers.end() && - !(_nextHandler->second & ~_nextHandler->first->_disabled & _nextHandler->first->_registered)) + !(_nextHandler->second & ~_nextHandler->first->_disabled & _nextHandler->first->_registered)) { ++_nextHandler; } @@ -764,7 +764,7 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread) 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)); + _threadIdleTime)); #endif } catch(const SelectorTimeoutException&) @@ -815,7 +815,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&) @@ -989,6 +989,14 @@ IceInternal::ThreadPool::startMessage(ThreadPoolCurrent& current) _workQueue->queue(new FinishedWorkItem(current._handler, false)); _selector.finish(current._handler.get()); } +#ifdef ICE_OS_UWP + // If async operations are no longer pending, clear the completion handler to break + // the cyclic reference count. + if(!current._handler->_started) + { + current._handler->getNativeInfo()->setCompletedHandler(nullptr); + } +#endif return false; } } |