diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 822ce36a..72bd104a 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -681,9 +681,15 @@ int HttpsUpstream::on_downstream_body(Downstream *downstream, return -1; } } - evbuffer_add(output, data, len); + if(evbuffer_add(output, data, len) != 0) { + ULOG(FATAL, this) << "evbuffer_add() failed"; + return -1; + } if(downstream->get_chunked_response()) { - evbuffer_add(output, "\r\n", 2); + if(evbuffer_add(output, "\r\n", 2) != 0) { + ULOG(FATAL, this) << "evbuffer_add() failed"; + return -1; + } } return 0; } diff --git a/src/shrpx_listen_handler.cc b/src/shrpx_listen_handler.cc index 3b9aa5a0..4a9cf4ba 100644 --- a/src/shrpx_listen_handler.cc +++ b/src/shrpx_listen_handler.cc @@ -109,7 +109,10 @@ int ListenHandler::accept_connection(evutil_socket_t fd, memcpy(&wev.client_addr, addr, addrlen); wev.client_addrlen = addrlen; evbuffer *output = bufferevent_get_output(workers_[idx].bev); - evbuffer_add(output, &wev, sizeof(wev)); + if(evbuffer_add(output, &wev, sizeof(wev)) != 0) { + LLOG(FATAL, this) << "evbuffer_add() failed"; + return -1; + } } return 0; } diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index f177d860..5a7a27c9 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -228,8 +228,11 @@ void eventcb(bufferevent *bev, short events, void *ptr) } int fd = bufferevent_getfd(bev); int val = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, - reinterpret_cast(&val), sizeof(val)); + if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&val), sizeof(val)) == -1) { + SSLOG(WARNING, spdy) << "Setting option TCP_NODELAY failed: " + << strerror(errno); + } } else if(events & BEV_EVENT_EOF) { if(LOG_ENABLED(INFO)) { SSLOG(INFO, spdy) << "EOF"; diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 85608ef1..dfdff29f 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -508,8 +508,11 @@ void spdy_downstream_eventcb(bufferevent *bev, short events, void *ptr) } int fd = bufferevent_getfd(bev); int val = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, - reinterpret_cast(&val), sizeof(val)); + if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&val), sizeof(val)) == -1) { + DCLOG(WARNING, dconn) << "Setting option TCP_NODELAY failed: " + << strerror(errno); + } } else if(events & BEV_EVENT_EOF) { if(LOG_ENABLED(INFO)) { DCLOG(INFO, dconn) << "EOF. stream_id=" << downstream->get_stream_id(); diff --git a/src/shrpx_thread_event_receiver.cc b/src/shrpx_thread_event_receiver.cc index 3192f6ee..f29a169d 100644 --- a/src/shrpx_thread_event_receiver.cc +++ b/src/shrpx_thread_event_receiver.cc @@ -46,7 +46,12 @@ void ThreadEventReceiver::on_read(bufferevent *bev) evbuffer *input = bufferevent_get_input(bev); while(evbuffer_get_length(input) >= sizeof(WorkerEvent)) { WorkerEvent wev; - evbuffer_remove(input, &wev, sizeof(WorkerEvent)); + int nread = evbuffer_remove(input, &wev, sizeof(wev)); + if(nread != sizeof(wev)) { + TLOG(FATAL, this) << "evbuffer_remove() removed fewer bytes. Expected:" + << sizeof(wev) << " Actual:" << nread; + continue; + } if(LOG_ENABLED(INFO)) { TLOG(INFO, this) << "WorkerEvent: client_fd=" << wev.client_fd << ", addrlen=" << wev.client_addrlen;