Open peterguo97 opened 2 years ago
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而导致返回,引发后续错误
好的,感谢反馈。我尽快修复一下。或者你也可以修复,我再帮你合并下
此处是否有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而导致返回,引发后续错误