http_conn::write中更新m_iv[0].iov_len的逻辑不对——codeRefactorCGI_version分支#185
Open
ning2510 wants to merge 3 commits intoqinguoyi:codeRefactorCGI_versionfrom
Open
http_conn::write中更新m_iv[0].iov_len的逻辑不对——codeRefactorCGI_version分支#185ning2510 wants to merge 3 commits intoqinguoyi:codeRefactorCGI_versionfrom
ning2510 wants to merge 3 commits intoqinguoyi:codeRefactorCGI_versionfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题所在
这里减的是
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。第一次调用writev后m_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