From ee2320663d52df1971da40b545ce46dd74666827 Mon Sep 17 00:00:00 2001 From: lizhen9880 Date: Thu, 21 May 2020 14:45:13 +0800 Subject: [PATCH] =?UTF-8?q?[fix=20bug]update=20ports/rtthread/HAL=5FTCP=5F?= =?UTF-8?q?rtthread.c.=20=E4=BF=AE=E5=A4=8D=20[github=20issues=20#32](http?= =?UTF-8?q?s://github.com/ucloud/ucloud-iot-rtthread-package/issues/32)=20?= =?UTF-8?q?=E4=B8=AD=E6=8F=90=E5=8F=8A=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ports/rtthread/HAL_TCP_rtthread.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ports/rtthread/HAL_TCP_rtthread.c b/ports/rtthread/HAL_TCP_rtthread.c index 9780c0f..bfde20f 100644 --- a/ports/rtthread/HAL_TCP_rtthread.c +++ b/ports/rtthread/HAL_TCP_rtthread.c @@ -172,10 +172,20 @@ int32_t HAL_TCP_Read(_IN_ uintptr_t fd, _OU_ unsigned char *buf, _IN_ size_t len ret = recv(tcp_fd, buf + len_recv, len - len_recv, MSG_DONTWAIT); if (ret > 0) { len_recv += ret; - }else if (errno == EINTR || errno == EAGAIN){ + } + else if (0 == ret) + { + break; + } + else + { + if (errno == EINTR || errno == EAGAIN) + { + continue; + } printf("read fail,try again\n"); err_code = ERR_TCP_READ_FAILED; - continue; + break; } } while (len_recv < len); -- Gitee