Fix bugs found by coverity scan
This commit is contained in:
parent
70c0558443
commit
3931a0b04d
|
@ -422,7 +422,11 @@ static int server_init(server *serv, const char *node, const char *service)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, optlen);
|
rv = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, optlen);
|
||||||
|
|
||||||
|
if(rv == -1) {
|
||||||
|
print_errno("setsockopt", errno);
|
||||||
|
}
|
||||||
|
|
||||||
if(bind(fd, rp->ai_addr, rp->ai_addrlen) != 0) {
|
if(bind(fd, rp->ai_addr, rp->ai_addrlen) != 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -552,8 +556,11 @@ static int handle_timer(io_loop *loop, uint32_t events, void *ptr)
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
|
||||||
while((nread = read(tmr->fd, buf, sizeof(buf))) == -1 && errno == EINTR);
|
while((nread = read(tmr->fd, buf, sizeof(buf))) == -1 && errno == EINTR);
|
||||||
|
|
||||||
|
if(nread == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update_date();
|
update_date();
|
||||||
|
|
||||||
|
@ -566,6 +573,7 @@ static int handle_accept(io_loop *loop, uint32_t events, void *ptr)
|
||||||
server *serv = ptr;
|
server *serv = ptr;
|
||||||
int on = 1;
|
int on = 1;
|
||||||
socklen_t optlen = sizeof(on);
|
socklen_t optlen = sizeof(on);
|
||||||
|
int rv;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
connection *conn;
|
connection *conn;
|
||||||
|
@ -574,7 +582,7 @@ static int handle_accept(io_loop *loop, uint32_t events, void *ptr)
|
||||||
errno == EINTR);
|
errno == EINTR);
|
||||||
|
|
||||||
if(acfd == -1) {
|
if(acfd == -1) {
|
||||||
switch(acfd) {
|
switch(errno) {
|
||||||
case ENETDOWN:
|
case ENETDOWN:
|
||||||
case EPROTO:
|
case EPROTO:
|
||||||
case ENOPROTOOPT:
|
case ENOPROTOOPT:
|
||||||
|
@ -588,7 +596,11 @@ static int handle_accept(io_loop *loop, uint32_t events, void *ptr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
setsockopt(acfd, IPPROTO_TCP, TCP_NODELAY, &on, optlen);
|
rv = setsockopt(acfd, IPPROTO_TCP, TCP_NODELAY, &on, optlen);
|
||||||
|
|
||||||
|
if(rv == -1) {
|
||||||
|
print_errno("setsockopt", errno);
|
||||||
|
}
|
||||||
|
|
||||||
conn = connection_new(acfd);
|
conn = connection_new(acfd);
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,11 @@ Config::Config()
|
||||||
nghttp2_option_set_recv_client_preface(session_option, 1);
|
nghttp2_option_set_recv_client_preface(session_option, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config::~Config()
|
||||||
|
{
|
||||||
|
nghttp2_option_del(session_option);
|
||||||
|
}
|
||||||
|
|
||||||
Stream::Stream(Http2Handler *handler, int32_t stream_id)
|
Stream::Stream(Http2Handler *handler, int32_t stream_id)
|
||||||
: handler(handler),
|
: handler(handler),
|
||||||
rtimer(nullptr),
|
rtimer(nullptr),
|
||||||
|
@ -512,7 +517,9 @@ int Http2Handler::on_read()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
evbuffer_drain(input, len);
|
if(evbuffer_drain(input, len) == -1) {
|
||||||
|
std::cerr << "evbuffer_drain() failed" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return send();
|
return send();
|
||||||
|
@ -1268,7 +1275,9 @@ void worker_readcb(bufferevent *bev, void *arg)
|
||||||
auto input = bufferevent_get_input(bev);
|
auto input = bufferevent_get_input(bev);
|
||||||
while(evbuffer_get_length(input) >= sizeof(ClientInfo)) {
|
while(evbuffer_get_length(input) >= sizeof(ClientInfo)) {
|
||||||
ClientInfo client;
|
ClientInfo client;
|
||||||
evbuffer_remove(input, &client, sizeof(client));
|
if(evbuffer_remove(input, &client, sizeof(client)) == -1) {
|
||||||
|
std::cerr << "evbuffer_remove() failed" << std::endl;
|
||||||
|
}
|
||||||
sessions->accept_connection(client.fd);
|
sessions->accept_connection(client.fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ struct Config {
|
||||||
bool error_gzip;
|
bool error_gzip;
|
||||||
bool early_response;
|
bool early_response;
|
||||||
Config();
|
Config();
|
||||||
|
~Config();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Http2Handler;
|
class Http2Handler;
|
||||||
|
|
Loading…
Reference in New Issue