Skip to content

Commit

Permalink
提高遍历性能
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-chu committed Jun 24, 2024
1 parent c898cb4 commit 843b40a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Network/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -334,6 +334,7 @@ class MMsgBuffer {
count = recvmmsg(fd, &_mmsgs[0], _mmsgs.size(), 0, nullptr);

Check warning on line 334 in src/Network/Socket.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
} while (-1 == count && UV_EINTR == get_uv_error(true));

_last_count = count;
if (count <= 0) {
return count;
}
Expand Down Expand Up @@ -368,6 +369,7 @@ class MMsgBuffer {

private:
size_t _size;
size_t _last_count { 0 };
std::vector<struct iovec> _iovec;
std::vector<struct mmsghdr> _mmsgs;
std::vector<Buffer::Ptr> _buffers;
Expand Down

0 comments on commit 843b40a

Please sign in to comment.