Fix broken nghttp2_bufs_avail

This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-14 00:24:34 +09:00
parent aefc0d1ebb
commit d48eca60cf
1 changed files with 8 additions and 1 deletions

View File

@ -24,6 +24,8 @@
*/
#include "nghttp2_buf.h"
#include <stdio.h>
#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;