From 12631cf162560150b056bb6565d87d8bb58fa2e8 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Thu, 5 Jan 2017 15:44:10 +0100 Subject: Fixed ICE-7419 - spurious error message from kqueue selector --- cpp/src/Ice/Selector.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'cpp') diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp index af568dccac7..b60669446d8 100644 --- a/cpp/src/Ice/Selector.cpp +++ b/cpp/src/Ice/Selector.cpp @@ -22,6 +22,13 @@ using namespace std; using namespace IceInternal; +#if defined(ICE_USE_KQUEUE) +namespace +{ +struct timespec zeroTimeout = { 0, 0 }; +} +#endif + #ifdef ICE_OS_WINRT using namespace Windows::Foundation; using namespace Windows::Storage::Streams; @@ -450,12 +457,27 @@ Selector::finish(EventHandler* handler, bool closeNow) void Selector::updateSelector() { - int rs = kevent(_queueFd, &_changes[0], _changes.size(), 0, 0, 0); + int rs = kevent(_queueFd, &_changes[0], _changes.size(), &_changes[0], _changes.size(), &zeroTimeout); if(rs < 0) { Ice::Error out(_instance->initializationData().logger); out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno()); } + else + { + for(int i = 0; i < rs; ++i) + { + // + // Check for errors, we ignore EINPROGRESS that started showing up with macOS Sierra + // and which occurs when another thread removes the FD from the kqueue (see ICE-7419). + // + if(_changes[i].flags & EV_ERROR && _changes[i].data != EINPROGRESS) + { + Ice::Error out(_instance->initializationData().logger); + out << "error while updating selector:\n" << IceUtilInternal::errorToString(_changes[i].data); + } + } + } _changes.clear(); } #endif -- cgit v1.2.3