From d48eca60cffdbe0a8a916e8105b5c2e260b3e28b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 14 Mar 2014 00:24:34 +0900 Subject: [PATCH] Fix broken nghttp2_bufs_avail --- lib/nghttp2_buf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/nghttp2_buf.c b/lib/nghttp2_buf.c index d729e1fc..9749145f 100644 --- a/lib/nghttp2_buf.c +++ b/lib/nghttp2_buf.c @@ -24,6 +24,8 @@ */ #include "nghttp2_buf.h" +#include + #include "nghttp2_helper.h" void nghttp2_buf_init(nghttp2_buf *buf) @@ -197,7 +199,7 @@ ssize_t nghttp2_bufs_len(nghttp2_bufs *bufs) static int nghttp2_bufs_avail(nghttp2_bufs *bufs) { return nghttp2_buf_avail(&bufs->cur->buf) + - (bufs->chunk_left - bufs->offset) * bufs->chunk_left; + (bufs->chunk_length - bufs->offset) * bufs->chunk_left; } static int nghttp2_bufs_alloc_chain(nghttp2_bufs *bufs) @@ -220,6 +222,10 @@ static int nghttp2_bufs_alloc_chain(nghttp2_bufs *bufs) return rv; } + DEBUGF(fprintf(stderr, + "new buffer %zu bytes allocated for bufs %p, left %zu\n", + bufs->chunk_length, bufs, bufs->chunk_left)); + --bufs->chunk_left; bufs->cur->next = chain; @@ -254,6 +260,7 @@ int nghttp2_bufs_add(nghttp2_bufs *bufs, const void *data, size_t len) } continue; } + buf->last = nghttp2_cpymem(buf->last, p, nwrite); p += len; len -= nwrite;