From 843b40ac0f4dadc774fcaeb736d452309343538e Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 24 Jun 2024 22:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E9=AB=98=E9=81=8D=E5=8E=86=E6=80=A7?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Network/Socket.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Network/Socket.cpp b/src/Network/Socket.cpp index 6841c38a..67946259 100644 --- a/src/Network/Socket.cpp +++ b/src/Network/Socket.cpp @@ -319,7 +319,7 @@ class MMsgBuffer { } ssize_t recvFromSocket(int fd, ssize_t &count) { - for (auto i = 0u; i < _mmsgs.size(); ++i) { + for (auto i = 0u; i < _last_count; ++i) { auto &mmsg = _mmsgs[i]; mmsg.msg_hdr.msg_namelen = sizeof(struct sockaddr_storage); auto &buf = _buffers[i]; @@ -334,6 +334,7 @@ class MMsgBuffer { count = recvmmsg(fd, &_mmsgs[0], _mmsgs.size(), 0, nullptr); } while (-1 == count && UV_EINTR == get_uv_error(true)); + _last_count = count; if (count <= 0) { return count; } @@ -368,6 +369,7 @@ class MMsgBuffer { private: size_t _size; + size_t _last_count { 0 }; std::vector _iovec; std::vector _mmsgs; std::vector _buffers;