http_conn::write中更新m_iv[0].iov_len的逻辑不对——codeRefactorCGI_version分支 #185
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