Merge pull request #1707 from nghttp2/fix-nghttpd-tls-read-stall

nghttpd: Fix TLS read stall
This commit is contained in:
Tatsuhiro Tsujikawa 2022-05-08 18:25:58 +09:00 committed by GitHub
commit c8a032b6f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 27 deletions

View File

@ -749,37 +749,37 @@ int Http2Handler::read_tls() {
ERR_clear_error(); ERR_clear_error();
auto rv = SSL_read(ssl_, buf.data(), buf.size()); for (;;) {
auto rv = SSL_read(ssl_, buf.data(), buf.size());
if (rv <= 0) { if (rv <= 0) {
auto err = SSL_get_error(ssl_, rv); auto err = SSL_get_error(ssl_, rv);
switch (err) { switch (err) {
case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_READ:
return write_(*this); return write_(*this);
case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_WRITE:
// renegotiation started // renegotiation started
return -1; return -1;
default: default:
return -1;
}
}
auto nread = rv;
if (get_config()->hexdump) {
util::hexdump(stdout, buf.data(), nread);
}
rv = nghttp2_session_mem_recv(session_, buf.data(), nread);
if (rv < 0) {
if (rv != NGHTTP2_ERR_BAD_CLIENT_MAGIC) {
std::cerr << "nghttp2_session_mem_recv() returned error: "
<< nghttp2_strerror(rv) << std::endl;
}
return -1; return -1;
} }
} }
auto nread = rv;
if (get_config()->hexdump) {
util::hexdump(stdout, buf.data(), nread);
}
rv = nghttp2_session_mem_recv(session_, buf.data(), nread);
if (rv < 0) {
if (rv != NGHTTP2_ERR_BAD_CLIENT_MAGIC) {
std::cerr << "nghttp2_session_mem_recv() returned error: "
<< nghttp2_strerror(rv) << std::endl;
}
return -1;
}
return write_(*this);
} }
int Http2Handler::write_tls() { int Http2Handler::write_tls() {