From: Pierre-Marc Fournier Date: Thu, 11 Jun 2009 18:02:21 +0000 (-0400) Subject: libust: fix problem in computation of offset in buffer X-Git-Tag: v0.1~218 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=64d9b80b1e4dfbb0c8329ed950d1c0d4de3e4c7a;p=ust.git libust: fix problem in computation of offset in buffer --- diff --git a/libust/relay.h b/libust/relay.h index 7d582a8..6b3a8b7 100644 --- a/libust/relay.h +++ b/libust/relay.h @@ -21,6 +21,8 @@ //ust// #include //ust// #include //ust// #include +#include +#include "tracer.h" #include "kref.h" //#include "list.h" #include "channels.h" @@ -290,13 +292,16 @@ static inline int ltt_relay_write(struct rchan_buf *buf, size_t offset, //ust// _ltt_relay_write(buf, offset, src, len, page, pagecpy); //ust// return len; - size_t cpy; - cpy = min_t(size_t, len, buf->buf_size - offset); - ltt_relay_do_copy(buf->buf_data + offset, src, cpy); + size_t buf_offset = BUFFER_OFFSET(offset, buf->chan); + + assert(buf_offset < buf->chan->subbuf_size*buf->chan->n_subbufs); + + cpy = min_t(size_t, len, buf->buf_size - buf_offset); + ltt_relay_do_copy(buf->buf_data + buf_offset, src, cpy); if (unlikely(len != cpy)) - _ltt_relay_write(buf, offset, src, len, cpy); + _ltt_relay_write(buf, buf_offset, src, len, cpy); return len; }