peadar@fatlenny$ diff -Nuw apps/buffering.c.0 apps/buffering.c
--- apps/buffering.c.0 2011-01-11 00:01:50.000000000 +0000
+++ apps/buffering.c 2011-01-22 01:50:57.000000000 +0000
@@ -681,7 +681,7 @@
* If this is true, then there's a handle even though we have still
* data to buffer. This should NEVER EVER happen! (but it does :( ) */
if (h->next && (overlap
- = ringbuf_add_cross(h->widx, copy_n, next_handle)) > 0)
+ = ringbuf_add_cross(h->widx, copy_n, next_handle)) >= 0)
{
/* stop buffering data for now and post-pone buffering the rest */
stop = true;
@@ -689,7 +689,11 @@
" copy_n:%lu overlap:%ld h1.filerem:%lu\n", __func__,
h->id, h->next->id, (unsigned long)copy_n, (long)overlap,
(unsigned long)h->filerem);
- copy_n -= overlap;
+ if (overlap == (ssize_t)copy_n) {
+ DEBUGF("%u: buffer_handle(%d): READ NOTHING\n", thread_get_current(), handle_id);
+ return false;
+ }
+ copy_n -= overlap + 1;
}
/* rc is the actual amount read */