From 3cdd00a59b65532b4c3a999d4cbfec1196b2ee4e Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Fri, 1 Oct 2021 10:56:42 -0700 Subject: [PATCH] Add IsSelectResultValid to LayerImplSelect --- src/system/SystemLayerImplSelect.cpp | 2 +- src/system/SystemLayerImplSelect.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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);