Fix errors reported by coverity scan
This commit is contained in:
parent
b8a43db84c
commit
6f967c6ef3
|
@ -624,33 +624,30 @@ int Http2Handler::read_clear() {
|
|||
int rv;
|
||||
std::array<uint8_t, 8_k> buf;
|
||||
|
||||
for (;;) {
|
||||
ssize_t nread;
|
||||
while ((nread = read(fd_, buf.data(), buf.size())) == -1 && errno == EINTR)
|
||||
;
|
||||
if (nread == -1) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (nread == 0) {
|
||||
return -1;
|
||||
ssize_t nread;
|
||||
while ((nread = read(fd_, buf.data(), buf.size())) == -1 && errno == EINTR)
|
||||
;
|
||||
if (nread == -1) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
return write_(*this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (nread == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (get_config()->hexdump) {
|
||||
util::hexdump(stdout, buf.data(), nread);
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return write_(*this);
|
||||
|
@ -746,40 +743,36 @@ int Http2Handler::read_tls() {
|
|||
|
||||
ERR_clear_error();
|
||||
|
||||
for (;;) {
|
||||
auto rv = SSL_read(ssl_, buf.data(), buf.size());
|
||||
auto rv = SSL_read(ssl_, buf.data(), buf.size());
|
||||
|
||||
if (rv <= 0) {
|
||||
auto err = SSL_get_error(ssl_, rv);
|
||||
switch (err) {
|
||||
case SSL_ERROR_WANT_READ:
|
||||
goto fin;
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
// renegotiation started
|
||||
return -1;
|
||||
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;
|
||||
}
|
||||
if (rv <= 0) {
|
||||
auto err = SSL_get_error(ssl_, rv);
|
||||
switch (err) {
|
||||
case SSL_ERROR_WANT_READ:
|
||||
return write_(*this);
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
// renegotiation started
|
||||
return -1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
fin:
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -505,7 +505,8 @@ struct DownstreamAddrGroupConfig {
|
|||
DownstreamAddrGroupConfig(const StringRef &pattern)
|
||||
: pattern(pattern),
|
||||
affinity{SessionAffinity::NONE},
|
||||
redirect_if_not_tls(false) {}
|
||||
redirect_if_not_tls(false),
|
||||
timeout{} {}
|
||||
|
||||
StringRef pattern;
|
||||
StringRef mruby_file;
|
||||
|
|
|
@ -469,9 +469,9 @@ int Connection::tls_handshake() {
|
|||
<< ERR_error_string(ERR_get_error(), nullptr);
|
||||
}
|
||||
|
||||
struct iovec iov;
|
||||
auto iovcnt = tls.wbuf.riovec(&iov, 1);
|
||||
auto nwrite = writev_clear(&iov, iovcnt);
|
||||
struct iovec iov[1];
|
||||
auto iovcnt = tls.wbuf.riovec(iov, 1);
|
||||
auto nwrite = writev_clear(iov, iovcnt);
|
||||
if (nwrite > 0) {
|
||||
tls.wbuf.drain(nwrite);
|
||||
}
|
||||
|
|
|
@ -1097,6 +1097,7 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream,
|
|||
|
||||
auto status = resp.fs.header(http2::HD__STATUS);
|
||||
// libnghttp2 guarantees this exists and can be parsed
|
||||
assert(status);
|
||||
auto status_code = http2::parse_http_status_code(status->value);
|
||||
|
||||
resp.http_status = status_code;
|
||||
|
|
|
@ -190,7 +190,8 @@ struct SharedDownstreamAddr {
|
|||
SharedDownstreamAddr()
|
||||
: balloc(1024, 1024),
|
||||
affinity{SessionAffinity::NONE},
|
||||
redirect_if_not_tls{false} {}
|
||||
redirect_if_not_tls{false},
|
||||
timeout{} {}
|
||||
|
||||
SharedDownstreamAddr(const SharedDownstreamAddr &) = delete;
|
||||
SharedDownstreamAddr(SharedDownstreamAddr &&) = delete;
|
||||
|
|
Loading…
Reference in New Issue