nghttpx: Use return 0 instead of break for readability

This commit is contained in:
Tatsuhiro Tsujikawa 2015-02-21 17:08:03 +09:00
parent a26a597453
commit c84a190ac7
2 changed files with 21 additions and 30 deletions

View File

@ -835,12 +835,12 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
auto sd = static_cast<StreamData *>( auto sd = static_cast<StreamData *>(
nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if (!sd || !sd->dconn) { if (!sd || !sd->dconn) {
break; return 0;
} }
auto downstream = sd->dconn->get_downstream(); auto downstream = sd->dconn->get_downstream();
if (!downstream || if (!downstream ||
downstream->get_downstream_stream_id() != frame->hd.stream_id) { downstream->get_downstream_stream_id() != frame->hd.stream_id) {
break; return 0;
} }
auto upstream = downstream->get_upstream(); auto upstream = downstream->get_upstream();
@ -867,13 +867,13 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
} }
call_downstream_readcb(http2session, downstream); call_downstream_readcb(http2session, downstream);
break; return 0;
} }
case NGHTTP2_HEADERS: { case NGHTTP2_HEADERS: {
auto sd = static_cast<StreamData *>( auto sd = static_cast<StreamData *>(
nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if (!sd || !sd->dconn) { if (!sd || !sd->dconn) {
break; return 0;
} }
auto downstream = sd->dconn->get_downstream(); auto downstream = sd->dconn->get_downstream();
@ -922,7 +922,7 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
// This may delete downstream // This may delete downstream
call_downstream_readcb(http2session, downstream); call_downstream_readcb(http2session, downstream);
break; return 0;
} }
case NGHTTP2_RST_STREAM: { case NGHTTP2_RST_STREAM: {
auto sd = static_cast<StreamData *>( auto sd = static_cast<StreamData *>(
@ -937,14 +937,14 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
call_downstream_readcb(http2session, downstream); call_downstream_readcb(http2session, downstream);
} }
} }
break; return 0;
} }
case NGHTTP2_SETTINGS: case NGHTTP2_SETTINGS:
if ((frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) { if ((frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) {
break; return 0;
} }
http2session->stop_settings_timer(); http2session->stop_settings_timer();
break; return 0;
case NGHTTP2_PUSH_PROMISE: case NGHTTP2_PUSH_PROMISE:
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
SSLOG(INFO, http2session) SSLOG(INFO, http2session)
@ -955,11 +955,10 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
// We just respond with RST_STREAM. // We just respond with RST_STREAM.
http2session->submit_rst_stream(frame->push_promise.promised_stream_id, http2session->submit_rst_stream(frame->push_promise.promised_stream_id,
NGHTTP2_REFUSED_STREAM); NGHTTP2_REFUSED_STREAM);
break; return 0;
default: default:
break; return 0;
} }
return 0;
} }
} // namespace } // namespace

View File

@ -358,7 +358,7 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
downstream->set_request_state(Downstream::MSG_COMPLETE); downstream->set_request_state(Downstream::MSG_COMPLETE);
} }
break; return 0;
} }
case NGHTTP2_HEADERS: { case NGHTTP2_HEADERS: {
auto downstream = upstream->find_downstream(frame->hd.stream_id); auto downstream = upstream->find_downstream(frame->hd.stream_id);
@ -386,22 +386,14 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
} }
} }
break; return 0;
}
case NGHTTP2_PRIORITY: {
// TODO comment out for now
// rv = downstream->change_priority(frame->priority.pri);
// if(rv != 0) {
// return NGHTTP2_ERR_CALLBACK_FAILURE;
// }
break;
} }
case NGHTTP2_SETTINGS: case NGHTTP2_SETTINGS:
if ((frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) { if ((frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) {
break; return 0;
} }
upstream->stop_settings_timer(); upstream->stop_settings_timer();
break; return 0;
case NGHTTP2_GOAWAY: case NGHTTP2_GOAWAY:
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
auto debug_data = util::ascii_dump(frame->goaway.opaque_data, auto debug_data = util::ascii_dump(frame->goaway.opaque_data,
@ -412,11 +404,10 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
<< ", error_code=" << frame->goaway.error_code << ", error_code=" << frame->goaway.error_code
<< ", debug_data=" << debug_data; << ", debug_data=" << debug_data;
} }
break; return 0;
default: default:
break; return 0;
} }
return 0;
} }
} // namespace } // namespace
@ -464,7 +455,7 @@ int on_frame_send_callback(nghttp2_session *session, const nghttp2_frame *frame,
if ((frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) { if ((frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) {
upstream->start_settings_timer(); upstream->start_settings_timer();
} }
break; return 0;
case NGHTTP2_PUSH_PROMISE: { case NGHTTP2_PUSH_PROMISE: {
auto downstream = make_unique<Downstream>( auto downstream = make_unique<Downstream>(
upstream, frame->push_promise.promised_stream_id, 0); upstream, frame->push_promise.promised_stream_id, 0);
@ -508,7 +499,7 @@ int on_frame_send_callback(nghttp2_session *session, const nghttp2_frame *frame,
upstream->add_pending_downstream(std::move(downstream)); upstream->add_pending_downstream(std::move(downstream));
upstream->start_downstream(ptr); upstream->start_downstream(ptr);
break; return 0;
} }
case NGHTTP2_GOAWAY: case NGHTTP2_GOAWAY:
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
@ -520,9 +511,10 @@ int on_frame_send_callback(nghttp2_session *session, const nghttp2_frame *frame,
<< ", error_code=" << frame->goaway.error_code << ", error_code=" << frame->goaway.error_code
<< ", debug_data=" << debug_data; << ", debug_data=" << debug_data;
} }
break; return 0;
default:
return 0;
} }
return 0;
} }
} // namespace } // namespace