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

TCP buffer处好像有一个bug #6

Open
peterguo97 opened this issue May 18, 2022 · 1 comment
Open

TCP buffer处好像有一个bug #6

peterguo97 opened this issue May 18, 2022 · 1 comment

Comments

@peterguo97
Copy link

void TcpBuffer::recycleWrite(int index) {
  int j = m_write_index + index;
  //TODO: here get a bug
  if (j >= (int)m_buffer.size()) {
    ErrorLog << "recycleWrite error";
    return;
  }
  m_write_index = j;
  adjustBuffer();
}

此处是否有bug,当buffer被填满时,例如
[2022-05-18 03:04:04.214972] [DEBUG] [29062] [29064] [1] [tinyrpc/net/tcp/tcp_connection.cc:114] m_read_buffer size=128rd=0wd=0
[2022-05-18 03:04:04.214988] [DEBUG] [29062] [29064] [1] [tinyrpc/coroutine/coroutine_hook.cc:55] this is hook read
[2022-05-18 03:04:04.214998] [DEBUG] [29062] [29064] [1] [tinyrpc/net/fd_event.cc:121] fd already set o_nonblock
[2022-05-18 03:04:04.215017] [DEBUG] [29062] [29064] [1] [tinyrpc/net/tcp/tcp_connection.cc:116] read_hook func get size: 128
此时读到了128个byte,但是在调用recycleWrite时,由于0+128 >= 128而导致返回,引发后续错误

@Gooddbird
Copy link
Owner

好的,感谢反馈。我尽快修复一下。或者你也可以修复,我再帮你合并下

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

No branches or pull requests

2 participants