Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI automatically translates all annotation content into English #245

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 50 additions & 25 deletions src/Network/Buffer.h
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review for src/Network/Buffer.h:

Code Review: Patch to src/Network/Buffer.h

Summary

This patch adds English translations for comments in the Buffer.h file. The translations are generally accurate and improve the readability of the code for non-Chinese speakers.

Detailed Feedback

Code Overview

The patch adds English translations for comments in the Buffer.h file. This improves the code's readability for developers who are not familiar with Chinese.

Strengths

  • Improved Readability: The English translations make the code more accessible to a wider audience.
  • Consistent Formatting: The translations are consistently formatted and placed in the correct locations.

Areas for Improvement

1. Translation Quality

  • Minor Inaccuracies: Some translations could be improved for clarity or accuracy. For example, "Object count statistics" could be more accurately translated as "Object Count Statistics" or "Object Statistics".
  • Redundancy: Some translations are redundant, as the original Chinese comment already conveys the meaning. For example, "Return data length" is already clear from the original comment "返回数据长度".

2. Code Style

  • Redundant Comments: Some comments are redundant, as the code itself is self-explanatory. For example, the comment "Set valid data size" is unnecessary because the function name setSize already indicates its purpose.

3. Best Practices

  • Use of const: The data() method should be declared as const to indicate that it does not modify the object's state.

Conclusion

The patch is a positive step towards improving the code's readability and accessibility. However, some minor improvements can be made to the translation quality, code style, and best practices.


This review was conducted by an AI assistant. While efforts have been made to ensure accuracy and thoroughness, human validation is recommended for critical decisions.

TRANS_BY_GITHUB_AI_ASSISTANT

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review for src/Network/Buffer.h:

Code Review: Patch to src/Network/Buffer.h

Summary

This patch adds English translations for comments in the Buffer.h file. The translations are generally accurate and improve the readability of the code for non-Chinese speakers.

Detailed Feedback

Code Overview

The patch adds English translations for comments in the Buffer.h file. This improves the code's readability for developers who are not familiar with Chinese.

Strengths

  • Improved Readability: The English translations make the code more accessible to a wider audience.
  • Consistent Formatting: The translations are consistently formatted and placed in the correct locations.

Areas for Improvement

1. Translation Quality

  • Minor Issues: Some translations could be improved for clarity and accuracy. For example, "Object count statistics" could be more concisely translated as "Object Count".
  • Suggestion: Review the translations carefully and make any necessary adjustments to ensure they are accurate and idiomatic.

2. Redundant Translations

  • Issue: Some comments are already in English, and the patch adds redundant translations. For example, the comment "Return data length" is already in English.
  • Suggestion: Remove redundant translations and focus on translating comments that are currently in Chinese.

3. Code Style

  • Issue: The patch introduces inconsistent use of spaces around the = operator in the setup function.
  • Suggestion: Ensure consistent spacing around operators throughout the code.

Conclusion

The patch is a positive step towards improving the code's readability for a wider audience. However, some minor improvements can be made to the translation quality, redundancy, and code style.


This review was conducted by an AI assistant. While efforts have been made to ensure accuracy and thoroughness, human validation is recommended for critical decisions.

TRANS_BY_GITHUB_AI_ASSISTANT

Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ template <typename T> struct is_pointer<std::shared_ptr<T const> > : public std:
template <typename T> struct is_pointer<T*> : public std::true_type {};
template <typename T> struct is_pointer<const T*> : public std::true_type {};

//缓存基类
//缓存基类 [AUTO-TRANSLATED:d130ab72]
//Cache base class
class Buffer : public noncopyable {
public:
using Ptr = std::shared_ptr<Buffer>;

Buffer() = default;
virtual ~Buffer() = default;

//返回数据长度
//返回数据长度 [AUTO-TRANSLATED:955f731c]
//Return data length
virtual char *data() const = 0;
virtual size_t size() const = 0;

Expand All @@ -49,7 +51,8 @@ class Buffer : public noncopyable {
}

private:
//对象个数统计
//对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
//Object count statistics
ObjectStatistic<Buffer> _statistic;
};

Expand Down Expand Up @@ -107,7 +110,8 @@ class BufferOffset : public Buffer {

using BufferString = BufferOffset<std::string>;

//指针式缓存对象,
//指针式缓存对象, [AUTO-TRANSLATED:c8403290]
//Pointer-style cache object,
class BufferRaw : public Buffer {
public:
using Ptr = std::shared_ptr<BufferRaw>;
Expand All @@ -120,32 +124,38 @@ class BufferRaw : public Buffer {
}
}

//在写入数据时请确保内存是否越界
//在写入数据时请确保内存是否越界 [AUTO-TRANSLATED:5602043e]
//When writing data, please ensure that the memory does not overflow
char *data() const override {
return _data;
}

//有效数据大小
//有效数据大小 [AUTO-TRANSLATED:b8dcbda7]
//Effective data size
size_t size() const override {
return _size;
}

//分配内存大小
//分配内存大小 [AUTO-TRANSLATED:cce87adf]
//Allocated memory size
void setCapacity(size_t capacity) {
if (_data) {
do {
if (capacity > _capacity) {
//请求的内存大于当前内存,那么重新分配
//请求的内存大于当前内存,那么重新分配 [AUTO-TRANSLATED:65306424]
//If the requested memory is greater than the current memory, reallocate
break;
}

if (_capacity < 2 * 1024) {
//2K以下,不重复开辟内存,直接复用
//2K以下,不重复开辟内存,直接复用 [AUTO-TRANSLATED:056416c0]
//Less than 2K, do not repeatedly allocate memory, reuse directly
return;
}

if (2 * capacity > _capacity) {
//如果请求的内存大于当前内存的一半,那么也复用
//如果请求的内存大于当前内存的一半,那么也复用 [AUTO-TRANSLATED:c189d660]
//If the requested memory is greater than half of the current memory, also reuse
return;
}
} while (false);
Expand All @@ -156,15 +166,17 @@ class BufferRaw : public Buffer {
_capacity = capacity;
}

//设置有效数据大小
//设置有效数据大小 [AUTO-TRANSLATED:efc4fb3e]
//Set valid data size
virtual void setSize(size_t size) {
if (size > _capacity) {
throw std::invalid_argument("Buffer::setSize out of range");
}
_size = size;
}

//赋值数据
//赋值数据 [AUTO-TRANSLATED:0b91b213]
//Assign data
void assign(const char *data, size_t size = 0) {
if (size <= 0) {
size = strlen(data);
Expand Down Expand Up @@ -196,7 +208,8 @@ class BufferRaw : public Buffer {
size_t _size = 0;
size_t _capacity = 0;
char *_data = nullptr;
//对象个数统计
//对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
//Object count statistics
ObjectStatistic<BufferRaw> _statistic;
};

Expand Down Expand Up @@ -275,39 +288,48 @@ class BufferLikeString : public Buffer {

BufferLikeString &erase(size_t pos = 0, size_t n = std::string::npos) {
if (pos == 0) {
//移除前面的数据
//移除前面的数据 [AUTO-TRANSLATED:b025d3c5]
//Remove data from the front
if (n != std::string::npos) {
//移除部分
//移除部分 [AUTO-TRANSLATED:a650bef2]
//Remove part
if (n > size()) {
//移除太多数据了
//移除太多数据了 [AUTO-TRANSLATED:64460d15]
//Removed too much data
throw std::out_of_range("BufferLikeString::erase out_of_range in head");
}
//设置起始便宜量
//设置起始便宜量 [AUTO-TRANSLATED:7a0250bd]
//Set starting offset
_erase_head += n;
data()[size()] = '\0';
return *this;
}
//移除全部数据
//移除全部数据 [AUTO-TRANSLATED:3d016f79]
//Remove all data
_erase_head = 0;
_erase_tail = _str.size();
data()[0] = '\0';
return *this;
}

if (n == std::string::npos || pos + n >= size()) {
//移除末尾所有数据
//移除末尾所有数据 [AUTO-TRANSLATED:efaf1165]
//Remove all data from the end
if (pos >= size()) {
//移除太多数据
//移除太多数据 [AUTO-TRANSLATED:dc9347c3]
//Removed too much data
throw std::out_of_range("BufferLikeString::erase out_of_range in tail");
}
_erase_tail += size() - pos;
data()[size()] = '\0';
return *this;
}

//移除中间的
//移除中间的 [AUTO-TRANSLATED:fd25344c]
//Remove the middle
if (pos + n > size()) {
//超过长度限制
//超过长度限制 [AUTO-TRANSLATED:9ae84929]
//Exceeds the length limit
throw std::out_of_range("BufferLikeString::erase out_of_range in middle");
}
_str.erase(_erase_head + pos, n);
Expand Down Expand Up @@ -415,14 +437,16 @@ class BufferLikeString : public Buffer {

std::string substr(size_t pos, size_t n = std::string::npos) const {
if (n == std::string::npos) {
//获取末尾所有的
//获取末尾所有的 [AUTO-TRANSLATED:8a0b92b6]
//Get all at the end
if (pos >= size()) {
throw std::out_of_range("BufferLikeString::substr out_of_range");
}
return _str.substr(_erase_head + pos, size() - pos);
}

//获取部分
//获取部分 [AUTO-TRANSLATED:d01310a4]
//Get part
if (pos + n > size()) {
throw std::out_of_range("BufferLikeString::substr out_of_range");
}
Expand All @@ -441,7 +465,8 @@ class BufferLikeString : public Buffer {
size_t _erase_head;
size_t _erase_tail;
std::string _str;
//对象个数统计
//对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
//Object count statistics
ObjectStatistic<BufferLikeString> _statistic;
};

Expand Down
75 changes: 50 additions & 25 deletions src/Network/BufferSock.cpp
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review for src/Network/BufferSock.cpp:

Code Review: Patch to src/Network/BufferSock.cpp

Summary

This patch focuses on improving the readability and clarity of the code by translating all the comments into English. It also adds some additional comments to clarify the logic in certain sections.

Detailed Feedback

Code Overview

The patch translates all the comments in the BufferSock.cpp file from Chinese to English. This improves the code's readability and accessibility for developers who are not familiar with Chinese.

Strengths

  • Improved Readability: The translation of comments makes the code much easier to understand for a wider audience.
  • Consistent Style: The translated comments maintain a consistent style and tone, making the code more cohesive.
  • Clearer Logic: The additional comments added in some sections help to clarify the logic and intent of the code.

Areas for Improvement

1. Translation Accuracy

  • Minor Issues: While the translation is generally accurate, there are a few instances where the translated comments could be improved for clarity and precision. For example, in the BufferSendMsg::send_l function, the comment "All written" could be more accurately translated as "All data written" or "All data sent".
  • Suggestion: Review the translated comments carefully and make any necessary adjustments to ensure accuracy and clarity.

2. Comment Style

  • Consistency: The comment style is generally consistent, but there are a few instances where the comments could be formatted more consistently. For example, some comments use a single line, while others use multiple lines.
  • Suggestion: Consider adopting a consistent style for comments, such as using a single line for short comments and multiple lines for longer explanations.

3. Code Structure

  • Function Length: Some functions, such as BufferSendMsg::send_l, are quite long and could be broken down into smaller, more manageable functions.
  • Suggestion: Consider refactoring the code to improve its modularity and readability.

Conclusion

This patch significantly improves the readability and accessibility of the code by translating the comments into English. However, there are a few minor areas for improvement related to translation accuracy, comment style, and code structure. Addressing these points will further enhance the code's quality and maintainability.


This review was conducted by an AI assistant. While efforts have been made to ensure accuracy and thoroughness, human validation is recommended for critical decisions.

TRANS_BY_GITHUB_AI_ASSISTANT

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review for src/Network/BufferSock.cpp:

Code Review: Patch to src/Network/BufferSock.cpp

Summary

This patch focuses on improving the readability and maintainability of the code by translating all the comments into English. It also adds some minor improvements to the code logic.

Detailed Feedback

Code Overview

The patch translates all the comments in the file from Chinese to English. This makes the code more accessible to a wider audience and improves its maintainability.

Strengths

  • Improved Readability: The translated comments make the code much easier to understand for developers who are not familiar with Chinese.
  • Increased Maintainability: English comments make it easier for developers to understand the code and make changes in the future.
  • Consistent Style: The translated comments are consistent with the existing English comments in the file.

Areas for Improvement

1. Redundant Comments

  • Issue: Some of the translated comments are redundant, as they simply restate the obvious. For example, the comment //All written in the send_l function is unnecessary because the code already clearly shows that the remaining size is set to zero.
  • Suggestion: Remove redundant comments to improve the clarity of the code.
  • Example:
    if (n >= (ssize_t)_remain_size) {
        //全部写完了  [AUTO-TRANSLATED:c990f48a]
        //All written
        _remain_size = 0;
        sendCompleted(true);
        return n;
    }
    Improved:
    if (n >= (ssize_t)_remain_size) {
        _remain_size = 0;
        sendCompleted(true);
        return n;
    }

2. Inconsistent Comment Style

  • Issue: Some comments use a more informal style than others. For example, the comment //sendto/send scheme, to be optimized uses a more casual tone than the comment //This is the last package sent.
  • Suggestion: Use a consistent style for all comments, such as using a more formal tone and avoiding slang.
  • Example:
    if (is_udp) {
        // sendto/send 方案,待优化  [AUTO-TRANSLATED:e94184aa]
        //sendto/send scheme, to be optimized
        return std::make_shared<BufferSendTo>(std::move(list), std::move(cb), is_udp);
    }
    Improved:
    if (is_udp) {
        // Use sendto/send scheme, which can be optimized.
        return std::make_shared<BufferSendTo>(std::move(list), std::move(cb), is_udp);
    }

3. Missing Comments

  • Issue: Some sections of the code lack comments, making it difficult to understand their purpose. For example, the reOffset function in the BufferSendMsg class lacks any comments explaining its functionality.
  • Suggestion: Add comments to explain the purpose of each function and the logic behind the code.
  • Example:
    void BufferSendMsg::reOffset(size_t n) {
        _remain_size -= n;
        size_t offset = 0;
        for (auto i = _iovec_off; i != _iovec.size(); ++i) {
            auto &ref = _iovec[i];
    #if !defined(_WIN32)
            offset += ref.iov_len;
    #else
            offset += ref.len;
    #endif
            if (offset < n) {
                //此包发送完毕  [AUTO-TRANSLATED:759b9f0e]
                //This package is sent
                sendFrontSuccess();
                continue;
            }
            _iovec_off = i;
            if (offset == n) {
                //这是末尾发送完毕的一个包  [AUTO-TRANSLATED:6a3b77e4]
                //This is the last package sent
                ++_iovec_off;
                sendFrontSuccess();
                break;
            }
            //这是末尾发送部分成功的一个包  [AUTO-TRANSLATED:64645cef]
            //This is the last package partially sent
            size_t remain = offset - n;
    #if !defined(_WIN32)
            ref.iov_base = (char *)ref.iov_base + ref.iov_len - remain;
            ref.iov_len = remain;
    #else
            ref.buf = (CHAR *)ref.buf + ref.len - remain;
            ref.len = remain;
    #endif
            break;
        }
    }
    Improved:
    // Adjust the offset of the iovec array based on the number of bytes sent.
    void BufferSendMsg::reOffset(size_t n) {
        _remain_size -= n;
        size_t offset = 0;
        for (auto i = _iovec_off; i != _iovec.size(); ++i) {
            auto &ref = _iovec[i];
    #if !defined(_WIN32)
            offset += ref.iov_len;
    #else
            offset += ref.len;
    #endif
            if (offset < n) {
                // This package is sent.
                sendFrontSuccess();
                continue;
            }
            _iovec_off = i;
            if (offset == n) {
                // This is the last package sent.
                ++_iovec_off;
                sendFrontSuccess();
                break;
            }
            // This is the last package partially sent.
            size_t remain = offset - n;
    #if !defined(_WIN32)
            ref.iov_base = (char *)ref.iov_base + ref.iov_len - remain;
            ref.iov_len = remain;
    #else
            ref.buf = (CHAR *)ref.buf + ref.len - remain;
            ref.len = remain;
    #endif
            break;
        }
    }

Conclusion

This patch significantly improves the readability and maintainability of the code by translating all the comments into English. However, there are still some areas for improvement, such as removing redundant comments, using a consistent comment style, and adding missing comments. Addressing these issues will further enhance the code's quality and make it easier for developers to understand and maintain.

TRANS_BY_GITHUB_AI_ASSISTANT

Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@

void sendCompleted(bool flag) {
if (_cb) {
//全部发送成功或失败回调
//全部发送成功或失败回调 [AUTO-TRANSLATED:6b9a9abf]
//All send success or failure callback
while (!_pkt_list.empty()) {
_cb(_pkt_list.front().first, flag);
_pkt_list.pop_front();
Expand All @@ -109,7 +110,8 @@

void sendFrontSuccess() {
if (_cb) {
//发送成功回调
//发送成功回调 [AUTO-TRANSLATED:52759efc]
//Send success callback
_cb(_pkt_list.front().first, true);
}
_pkt_list.pop_front();
Expand Down Expand Up @@ -183,19 +185,22 @@
#endif

if (n >= (ssize_t)_remain_size) {
//全部写完了
//全部写完了 [AUTO-TRANSLATED:c990f48a]
//All written
_remain_size = 0;
sendCompleted(true);
return n;
}

if (n > 0) {
//部分发送成功
//部分发送成功 [AUTO-TRANSLATED:4c240905]
//Partial send success
reOffset(n);
return n;
}

//一个字节都未发送
//一个字节都未发送 [AUTO-TRANSLATED:c33c611b]
//Not a single byte sent
return n;
}

Expand All @@ -205,10 +210,12 @@

ssize_t sent = remain_size - _remain_size;
if (sent > 0) {
//部分或全部发送成功
//部分或全部发送成功 [AUTO-TRANSLATED:a3f5e70e]
//Partial or all send success
return sent;
}
//一个字节都未发送成功
//一个字节都未发送成功 [AUTO-TRANSLATED:858b63e5]
//Not a single byte sent successfully
return -1;
}

Expand All @@ -223,25 +230,28 @@
offset += ref.len;
#endif
if (offset < n) {
//此包发送完毕
//此包发送完毕 [AUTO-TRANSLATED:759b9f0e]
//This package is sent
sendFrontSuccess();
continue;
}
_iovec_off = i;
if (offset == n) {
//这是末尾发送完毕的一个包
//这是末尾发送完毕的一个包 [AUTO-TRANSLATED:6a3b77e4]
//This is the last package sent
++_iovec_off;
sendFrontSuccess();
break;
}
//这是末尾发送部分成功的一个包
//这是末尾发送部分成功的一个包 [AUTO-TRANSLATED:64645cef]
//This is the last package partially sent
size_t remain = offset - n;
#if !defined(_WIN32)
ref.iov_base = (char *)ref.iov_base + ref.iov_len - remain;
ref.iov_len = remain;
#else
ref.buf = (CHAR *)ref.buf + ref.len - remain;
ref.len = remain;

Check warning on line 254 in src/Network/BufferSock.cpp

View workflow job for this annotation

GitHub Actions / build

'=': conversion from 'size_t' to 'ULONG', possible loss of data
#endif
break;
}
Expand All @@ -258,7 +268,7 @@
_remain_size += it->iov_len;
#else
it->buf = pr.first->data();
it->len = pr.first->size();

Check warning on line 271 in src/Network/BufferSock.cpp

View workflow job for this annotation

GitHub Actions / build

'=': conversion from 'size_t' to 'ULONG', possible loss of data
_remain_size += it->len;
#endif
++it;
Expand Down Expand Up @@ -307,9 +317,9 @@
auto &buffer = front.first;
if (_is_udp) {
auto ptr = getBufferSockPtr(front);
n = ::sendto(fd, buffer->data() + _offset, buffer->size() - _offset, flags, ptr ? ptr->sockaddr() : nullptr, ptr ? ptr->socklen() : 0);

Check warning on line 320 in src/Network/BufferSock.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
} else {
n = ::send(fd, buffer->data() + _offset, buffer->size() - _offset, flags);

Check warning on line 322 in src/Network/BufferSock.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
}

if (n >= 0) {
Expand All @@ -323,12 +333,15 @@
continue;
}

//n == -1的情况
//n == -1的情况 [AUTO-TRANSLATED:305fb5bc]
//n == -1 case
if (get_uv_error(true) == UV_EINTR) {
//被打断,需要继续发送
//被打断,需要继续发送 [AUTO-TRANSLATED:6ef0b34d]
//interrupted, need to continue sending
continue;
}
//其他原因导致的send返回-1
//其他原因导致的send返回-1 [AUTO-TRANSLATED:299cddb7]
//other reasons causing send to return -1
break;
}
return sent ? sent : -1;
Expand Down Expand Up @@ -372,12 +385,14 @@
} while (-1 == n && UV_EINTR == get_uv_error(true));

if (n > 0) {
//部分或全部发送成功
//部分或全部发送成功 [AUTO-TRANSLATED:a3f5e70e]
//partially or fully sent successfully
reOffset(n);
return n;
}

//一个字节都未发送
//一个字节都未发送 [AUTO-TRANSLATED:c33c611b]
//not a single byte sent
return n;
}

Expand All @@ -386,10 +401,12 @@
while (_remain_size && send_l(fd, flags) != -1);
ssize_t sent = remain_size - _remain_size;
if (sent > 0) {
//部分或全部发送成功
//部分或全部发送成功 [AUTO-TRANSLATED:a3f5e70e]
//partially or fully sent successfully
return sent;
}
//一个字节都未发送成功
//一个字节都未发送成功 [AUTO-TRANSLATED:858b63e5]
//not a single byte sent successfully
return -1;
}

Expand All @@ -400,12 +417,14 @@
assert(hdr.msg_len <= io.iov_len);
_remain_size -= hdr.msg_len;
if (hdr.msg_len == io.iov_len) {
//这个udp包全部发送成功
//这个udp包全部发送成功 [AUTO-TRANSLATED:fce1cc86]
//this UDP packet sent successfully
it = _hdrvec.erase(it);
sendFrontSuccess();
continue;
}
//部分发送成功
//部分发送成功 [AUTO-TRANSLATED:4c240905]
//partially sent successfully
io.iov_base = (char *)io.iov_base + hdr.msg_len;
io.iov_len -= hdr.msg_len;
break;
Expand Down Expand Up @@ -444,24 +463,30 @@
BufferList::Ptr BufferList::create(List<std::pair<Buffer::Ptr, bool> > list, SendResult cb, bool is_udp) {
#if defined(_WIN32)
if (is_udp) {
// sendto/send 方案,待优化
// sendto/send 方案,待优化 [AUTO-TRANSLATED:e94184aa]
//sendto/send scheme, to be optimized
return std::make_shared<BufferSendTo>(std::move(list), std::move(cb), is_udp);
}
// WSASend方案
// WSASend方案 [AUTO-TRANSLATED:9ac7bb81]
//WSASend scheme
return std::make_shared<BufferSendMsg>(std::move(list), std::move(cb));
#elif defined(__linux__) || defined(__linux)
if (is_udp) {
// sendmmsg方案
// sendmmsg方案 [AUTO-TRANSLATED:4596c2c4]
//sendmmsg scheme
return std::make_shared<BufferSendMMsg>(std::move(list), std::move(cb));
}
// sendmsg方案
// sendmsg方案 [AUTO-TRANSLATED:8846f9c4]
//sendmsg scheme
return std::make_shared<BufferSendMsg>(std::move(list), std::move(cb));
#else
if (is_udp) {
// sendto/send 方案, 可优化?
// sendto/send 方案, 可优化? [AUTO-TRANSLATED:21dbae7c]
//sendto/send scheme, can be optimized?
return std::make_shared<BufferSendTo>(std::move(list), std::move(cb), is_udp);
}
// sendmsg方案
// sendmsg方案 [AUTO-TRANSLATED:8846f9c4]
//sendmsg scheme
return std::make_shared<BufferSendMsg>(std::move(list), std::move(cb));
#endif
}
Expand Down Expand Up @@ -554,7 +579,7 @@
}

do {
nread = recvfrom(fd, _buffer->data(), _buffer->getCapacity() - 1, 0, (struct sockaddr *)&_address, &len);

Check warning on line 582 in src/Network/BufferSock.cpp

View workflow job for this annotation

GitHub Actions / build

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

if (nread > 0) {
Expand Down
Loading
Loading