nghttpx: Don't check downstream existence since dconn is one-to-one with it

This commit is contained in:
Tatsuhiro Tsujikawa 2016-09-15 22:11:26 +09:00
parent a100df9cae
commit 3e1cfa8e99
1 changed files with 37 additions and 69 deletions

View File

@ -737,7 +737,6 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
auto dconn = sd->dconn;
if (dconn) {
auto downstream = dconn->get_downstream();
if (downstream) {
auto upstream = downstream->get_upstream();
if (downstream->get_downstream_stream_id() % 2 == 0 &&
@ -777,7 +776,6 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
}
// dconn may be deleted
}
}
// The life time of StreamData ends here
http2session->remove_stream_data(sd);
return 0;
@ -806,9 +804,6 @@ int on_header_callback2(nghttp2_session *session, const nghttp2_frame *frame,
return 0;
}
auto downstream = sd->dconn->get_downstream();
if (!downstream) {
return 0;
}
auto namebuf = nghttp2_rcbuf_get_buf(name);
auto valuebuf = nghttp2_rcbuf_get_buf(value);
@ -918,10 +913,6 @@ int on_invalid_header_callback2(nghttp2_session *session,
if (!sd || !sd->dconn) {
return 0;
}
auto downstream = sd->dconn->get_downstream();
if (!downstream) {
return 0;
}
int32_t stream_id;
@ -966,12 +957,6 @@ int on_begin_headers_callback(nghttp2_session *session,
NGHTTP2_INTERNAL_ERROR);
return 0;
}
auto downstream = sd->dconn->get_downstream();
if (!downstream) {
http2session->submit_rst_stream(frame->hd.stream_id,
NGHTTP2_INTERNAL_ERROR);
return 0;
}
return 0;
}
case NGHTTP2_PUSH_PROMISE: {
@ -1132,10 +1117,6 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
return 0;
}
auto downstream = sd->dconn->get_downstream();
if (!downstream) {
return 0;
}
auto upstream = downstream->get_upstream();
rv = upstream->on_downstream_body(downstream, nullptr, 0, true);
if (rv != 0) {
@ -1170,10 +1151,6 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
}
auto downstream = sd->dconn->get_downstream();
if (!downstream) {
return 0;
}
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE ||
frame->headers.cat == NGHTTP2_HCAT_PUSH_RESPONSE) {
rv = on_response_headers(http2session, downstream, session, frame);
@ -1219,12 +1196,10 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if (sd && sd->dconn) {
auto downstream = sd->dconn->get_downstream();
if (downstream) {
downstream->set_response_rst_stream_error_code(
frame->rst_stream.error_code);
call_downstream_readcb(http2session, downstream);
}
}
return 0;
}
case NGHTTP2_SETTINGS: {
@ -1325,7 +1300,7 @@ int on_data_chunk_recv_callback(nghttp2_session *session, uint8_t flags,
return 0;
}
auto downstream = sd->dconn->get_downstream();
if (!downstream || !downstream->expect_response_body()) {
if (!downstream->expect_response_body()) {
http2session->submit_rst_stream(stream_id, NGHTTP2_INTERNAL_ERROR);
if (http2session->consume(stream_id, len) != 0) {
@ -1386,10 +1361,6 @@ int on_frame_send_callback(nghttp2_session *session, const nghttp2_frame *frame,
auto downstream = sd->dconn->get_downstream();
if (!downstream) {
return 0;
}
if (frame->hd.type == NGHTTP2_HEADERS &&
frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
downstream->set_request_header_sent(true);
@ -1438,9 +1409,6 @@ int on_frame_not_send_callback(nghttp2_session *session,
return 0;
}
auto downstream = sd->dconn->get_downstream();
if (!downstream) {
return 0;
}
if (lib_error_code == NGHTTP2_ERR_START_STREAM_NOT_ALLOWED) {
// Migrate to another downstream connection.
@ -1829,7 +1797,7 @@ void Http2Session::submit_pending_requests() {
for (auto dconn = dconns_.head; dconn; dconn = dconn->dlnext) {
auto downstream = dconn->get_downstream();
if (!downstream || !downstream->get_request_pending() ||
if (!downstream->get_request_pending() ||
!downstream->request_submission_ready()) {
continue;
}