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

麻烦您帮忙解释下,谢谢 #7

Open
Dayu0501 opened this issue Mar 23, 2020 · 0 comments
Open

麻烦您帮忙解释下,谢谢 #7

Dayu0501 opened this issue Mar 23, 2020 · 0 comments

Comments

@Dayu0501
Copy link

if (_curr_buf->status == cell_buffer::FREE) {
_curr_buf->status = cell_buffer::FULL; // set to FULL
cell_buffer* next_buf = _curr_buf->next;
// tell backend thread 通知消费者线程把cell中的log更新到文件。
tell_back = true;

  // it suggest that this buffer is under the persist job
  if (next_buf->status == cell_buffer::FULL) {
    // if mem use < MEM_USE_LIMIT, allocate new cell_buffer
    if (_one_buff_len * (_buff_cnt + 1) > MEM_USE_LIMIT) {
      fprintf(stderr, "no more log space can use\n");
      _curr_buf = next_buf;
      _lst_lts = curr_sec;
    } else {
      cell_buffer* new_buffer = new cell_buffer(_one_buff_len);
      _buff_cnt += 1;
      new_buffer->prev = _curr_buf;
      _curr_buf->next = new_buffer;
      new_buffer->next = next_buf;
      next_buf->prev = new_buffer;
      _curr_buf = new_buffer;
    }
  } else {
    // next buffer is free, we can use it
    _curr_buf = next_buf;
  }
  if (!_lst_lts) _curr_buf->append(log_line, len);
} else  //_curr_buf->status == cell_buffer::FULL, assert persist is on here
        // too!
{
  _lst_lts = curr_sec;
}

当cell buffer满了的时候,不是应该寻找下一个空的cell buffer吗,为什么这个是没有处理的?

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

1 participant