On 01/05/2010 02:27 AM, Pete Zaitcev wrote:
This patch fixes 3 plain coding bugs in the streaming mechanism.

1. Whenever we loop back to "restart" label, we have to clear n_iov.
    Otherwise, the loop that fills iov[] writes beyond the end of the
    array. The result is binary garbage on console and a hang.

    Behold the evils of initialized variables. Fix is obvious.

    BTW, array indexes are signed.

2. When we consume a queue element partially, we ought to advance its
    buffer pointer when we decrement the length. Otherwise, we resend
    the data that was sent already, causing a corruption in transfer.

    The fix is obvious (add tmp->buf += sz).

3. The accounting (through unfortunately named write_cnt) was incorrect
    because wr->len may be decremented by the time the element is freed.

Since we're at it, we implement a couple of safety improvements.
First, we change the API to the callback a little. From now on, it
does not have access to the struct client_write anymore, and cannot
accidentially rely on wr->buf (which can be changed now).
Also, we renamed "len" into "togo" and named the new member "length",
to make sure that all use instances for "len" were reviewed.

Signed-Off-By: Pete Zaitcev<[email protected]>

---
  server/object.c |    8 +++-----
  server/server.c |   31 ++++++++++++++++---------------
  server/tabled.h |   11 ++++++-----
  3 files changed, 25 insertions(+), 25 deletions(-)

applied...  chunkd needs these fixes also, yes?


--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to