diff --git a/src/system/SystemLayerImplSelect.cpp b/src/system/SystemLayerImplSelect.cpp index 0ac3bd3e7ad7bc..1feaf7d3feb7ad 100644 --- a/src/system/SystemLayerImplSelect.cpp +++ b/src/system/SystemLayerImplSelect.cpp @@ -373,7 +373,7 @@ void LayerImplSelect::HandleEvents() { assertChipStackLockedByCurrentThread(); - if (mSelectResult < 0) + if (!IsSelectResultValid()) { ChipLogError(DeviceLayer, "select failed: %s\n", ErrorStr(CHIP_ERROR_POSIX(errno))); return; diff --git a/src/system/SystemLayerImplSelect.h b/src/system/SystemLayerImplSelect.h index 9211971ea1c28a..d714f7929067a5 100644 --- a/src/system/SystemLayerImplSelect.h +++ b/src/system/SystemLayerImplSelect.h @@ -75,6 +75,9 @@ class LayerImplSelect : public LayerSocketsLoop void HandleTimerComplete(TimerList::Node * timer); #endif // CHIP_SYSTEM_CONFIG_USE_DISPATCH + // Expose the result of WaitForEvents() for non-blocking socket implementations. + bool IsSelectResultValid() const { return mSelectResult >= 0; } + protected: static SocketEvents SocketEventsFromFDs(int socket, const fd_set & readfds, const fd_set & writefds, const fd_set & exceptfds);