From 04289a908d2158616e4fcba8ff920fa369e7ca7b Mon Sep 17 00:00:00 2001 From: wuzhihuitmac Date: Thu, 2 Jan 2025 19:05:47 +0800 Subject: [PATCH] Delete duplicate receipts Signed-off-by: wuzhihuitmac Change-Id: I73953806d6a43f286284d12161b8dc7b0bb9363b --- .../common/src/sensor_basic_data_channel.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/utils/common/src/sensor_basic_data_channel.cpp b/utils/common/src/sensor_basic_data_channel.cpp index 7cd3109f..4b150c5e 100644 --- a/utils/common/src/sensor_basic_data_channel.cpp +++ b/utils/common/src/sensor_basic_data_channel.cpp @@ -201,7 +201,6 @@ int32_t SensorBasicDataChannel::ReceiveData(ClientExcuteCB callBack, void *vaddr return ERROR; } ssize_t length = 0; - int32_t retryCount = 0; for (int32_t i = 0; i < MAX_RECV_LIMIT; i++) { { std::unique_lock lock(fdLock_); @@ -211,17 +210,21 @@ int32_t SensorBasicDataChannel::ReceiveData(ClientExcuteCB callBack, void *vaddr } length = recv(receiveFd_, vaddr, size, MSG_DONTWAIT | MSG_NOSIGNAL); } - retryCount++; if (length > 0) { callBack(static_cast(length)); - } else { - if ((length < 0) && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) { - SEN_HILOGD("Continue for EAGAIN|EINTR|EWOULDBLOCK, errno:%{public}d, sendFd_:%{public}d", - errno, sendFd_); + } + if (length < 0) { + if (errno == EINTR) { + SEN_HILOGD("Continue for EINTR, errno:%{public}d, sendFd_:%{public}d", errno, sendFd_); continue; } - SEN_HILOGE("recv failed:%{public}s", ::strerror(errno)); - return ERROR; + if (errno == EAGAIN || errno == EWOULDBLOCK) { + SEN_HILOGD("No available data"); + } else { + SEN_HILOGE("recv failed:%{public}s", ::strerror(errno)); + return ERROR; + } + return ERR_OK; } }; return ERR_OK; -- Gitee