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

http_conn::write中更新m_iv[0].iov_len的逻辑不对——master分支 #184

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ning2510
Copy link

@ning2510 ning2510 commented Nov 20, 2022

问题所在
这里减的是 m_iv[0].iov_len - bytes_have_send,应该是 m_write_idx - bytes_have_send,说一下原因:

  • 如果第一个 iovec 的头部信息数据长度需要多次使用 writev 才能发送完的话,那么 m_iv[0].iov_len 就会重复减去相同的值
  • 举个例子:假设第一个 iovec 的头部信息数据长度为 90,每次 writev 发送的长度为 30。第一次调用 writevm_iv[0].iov_len = m_iv[0].iov_len - 30 = 90 - 30 = 60,第二次后 m_iv[0].iov_len = m_iv[0].iov_len - 60 = 60 - 60 = 0,实际还有 30 没有发送

m_write_idx 第一个 iovec 的头部信息数据长度,而且 m_write_idx 在循环发送的过程中是不会改变的,同时也应该改上面的 if 语句的 m_iv[0].iov_len 也改为 m_write_idx

Modify the update logic of m_iv[0].iov_len
@ning2510 ning2510 changed the title http_conn::write中更新m_iv[0].iov_len的逻辑不对 http_conn::write中更新m_iv[0].iov_len的逻辑不对——master分支 Nov 20, 2022
@codeduckerxyx
Copy link

有道理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants