nghttpd: Use evbuffer_pullup(input, -1) cause buffer is most likely just one

This commit is contained in:
Tatsuhiro Tsujikawa 2014-12-24 00:46:04 +09:00
parent 292f219900
commit a20ad03f7b
1 changed files with 13 additions and 18 deletions

View File

@ -440,26 +440,21 @@ int Http2Handler::on_read() {
int rv;
auto input = bufferevent_get_input(bev_);
auto len = evbuffer_get_length(input);
if (len == 0) {
return 0;
}
auto data = evbuffer_pullup(input, -1);
for (;;) {
auto len = evbuffer_get_contiguous_space(input);
rv = nghttp2_session_mem_recv(session_, data, len);
if (rv < 0) {
std::cerr << "nghttp2_session_mem_recv() returned error: "
<< nghttp2_strerror(rv) << std::endl;
return -1;
}
if (len == 0) {
break;
}
auto data = evbuffer_pullup(input, len);
rv = nghttp2_session_mem_recv(session_, data, len);
if (rv < 0) {
std::cerr << "nghttp2_session_mem_recv() returned error: "
<< nghttp2_strerror(rv) << std::endl;
return -1;
}
if (evbuffer_drain(input, len) == -1) {
std::cerr << "evbuffer_drain() failed" << std::endl;
}
if (evbuffer_drain(input, len) == -1) {
std::cerr << "evbuffer_drain() failed" << std::endl;
}
return send();