From bad085c644fe9351af3c306ebc93d14c9a4fdca0 Mon Sep 17 00:00:00 2001 From: alexhqwang <62671723+alexhqwang@users.noreply.github.com> Date: Thu, 20 Jan 2022 21:13:30 -0800 Subject: [PATCH] Add IsSelectResultValid to LayerImplSelect (#13776) --- 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);