Hello All,
I think we have a major flaw in first_write_block() in MIOBuffer, the
comment and code are the following:

  /**
    Returns a pointer to the first writable block on the block chain.
    Returns NULL if there are not currently any writable blocks on the
    block list.

  */
  IOBufferBlock *first_write_block()
  {
    if (_writer) {
      if (_writer->next && !_writer->write_avail())
        return _writer->next;
      ink_assert(!_writer->next || !_writer->next->read_avail());
      return _writer;
    } else
        return NULL;
  }


According to this comment it should find the first block with available
space or return NULL, obviously this code only examines two blocks and
(writer and writer->next). I think this code should be more like:

  IOBufferBlock *first_write_block()
  {
    for(IOBufferBlock *cur = _writer; cur != NULL; cur=cur->next) {
      if (cur->write_avail())
        return cur;
    }
    return NULL;
  }

Does anyone have comments on this? I'm not sure if this change will break
anything, so feedback will be appreciated.

Brian

Reply via email to