From 0c70ff56589e4b02c61a71d471adf1a45e23dc16 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 10 Dec 2015 23:18:02 +0900 Subject: [PATCH] Simplify --- lib/nghttp2_session.c | 74 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index a9829048..780ad5f1 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -2556,6 +2556,8 @@ static int session_after_frame_sent2(nghttp2_session *session) { nghttp2_bufs *framebufs = &aob->framebufs; nghttp2_frame *frame; nghttp2_mem *mem; + nghttp2_stream *stream; + nghttp2_data_aux_data *aux_data; mem = &session->mem; frame = &item->frame; @@ -2578,50 +2580,46 @@ static int session_after_frame_sent2(nghttp2_session *session) { active_outbound_item_reset(&session->aob, mem); return 0; - } else { - nghttp2_stream *stream; - nghttp2_data_aux_data *aux_data; + } - aux_data = &item->aux_data.data; + /* DATA frame */ - /* On EOF, we have already detached data. Please note that - application may issue nghttp2_submit_data() in - on_frame_send_callback (call from session_after_frame_sent1), - which attach data to stream. We don't want to detach it. */ - if (aux_data->eof) { - active_outbound_item_reset(aob, mem); + aux_data = &item->aux_data.data; - return 0; - } - - /* Reset no_copy here because next write may not use this. */ - aux_data->no_copy = 0; - - stream = nghttp2_session_get_stream(session, frame->hd.stream_id); - - /* If session is closed or RST_STREAM was queued, we won't send - further data. */ - if (nghttp2_session_predicate_data_send(session, stream) != 0) { - if (stream) { - rv = nghttp2_stream_detach_item(stream); - - if (nghttp2_is_fatal(rv)) { - return rv; - } - } - - active_outbound_item_reset(aob, mem); - - return 0; - } - - aob->item = NULL; - active_outbound_item_reset(&session->aob, mem); + /* On EOF, we have already detached data. Please note that + application may issue nghttp2_submit_data() in + on_frame_send_callback (call from session_after_frame_sent1), + which attach data to stream. We don't want to detach it. */ + if (aux_data->eof) { + active_outbound_item_reset(aob, mem); return 0; } - /* Unreachable */ - assert(0); + + /* Reset no_copy here because next write may not use this. */ + aux_data->no_copy = 0; + + stream = nghttp2_session_get_stream(session, frame->hd.stream_id); + + /* If session is closed or RST_STREAM was queued, we won't send + further data. */ + if (nghttp2_session_predicate_data_send(session, stream) != 0) { + if (stream) { + rv = nghttp2_stream_detach_item(stream); + + if (nghttp2_is_fatal(rv)) { + return rv; + } + } + + active_outbound_item_reset(aob, mem); + + return 0; + } + + aob->item = NULL; + active_outbound_item_reset(&session->aob, mem); + return 0; }