Skip to content

Commit

Permalink
Fixes skupperproject#904: Checks the response of the nghttp2_submit_h…
Browse files Browse the repository at this point in the history
…eaders and acc… (skupperproject#905)

* Fixes skupperproject#904: Checks the response of the nghttp2_submit_headers and accordingly sets the value of stream_data->stream_id

* Fixes skupperproject#904: Added vflow attributes VFLOW_ATTRIBUTE_RESULT and VFLOW_ATTRIBUTE_REASON
  • Loading branch information
ganeshmurthy committed Jan 18, 2023
1 parent 4477cf3 commit 01bd599
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/adaptors/http2/http2_adaptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1966,11 +1966,28 @@ uint64_t handle_outgoing_http(qdr_http2_stream_data_t *stream_data)
SET_ATOMIC_FLAG(&conn->delay_buffer_write);
}

stream_data->stream_id =
nghttp2_submit_headers(conn->session, flags, stream_id, NULL, hdrs, actual_count, stream_data);
int32_t ret_val = nghttp2_submit_headers(conn->session, flags, stream_id, NULL, hdrs, actual_count, stream_data);

// The call to nghttp2_submit_headers can return 3 possible values.
// 1. The new stream id > 0 if this is a request and the passed in stream id was -1.
// 2. zero if this is response and there was no error when submitting the response headers
// 3. returns an nghttp2 specific error code less than zero if there was some error calling nghttp2_submit_headers.
if (ret_val < 0) {
// An error code was returned by nghttp2 when calling nghttp2_submit_headers. This was a failure in submitting the headers
// Log the failure code returned by nghttp2 and do not proceed
qd_log(http2_adaptor->protocol_log_source, QD_LOG_ERROR, "[C%"PRIu64"] nghttp2_submit_headers failed, ret_val=%"PRId32", closing connection", conn->conn_id, ret_val);
// Since there was an error calling nghttp2_submit_headers, we cannot proceed further, we will have to close the connection
nghttp2_submit_goaway(conn->session, 0, stream_id, ret_val, (uint8_t *)"Error while submitting header", 29);
vflow_set_uint64(stream_data->vflow, VFLOW_ATTRIBUTE_RESULT, ret_val);
vflow_set_string(stream_data->vflow, VFLOW_ATTRIBUTE_REASON, nghttp2_strerror(ret_val));

if (stream_id != -1) {
stream_data->stream_id = stream_id;
pn_raw_connection_close(conn->pn_raw_conn);
return 0;
} else if (ret_val == 0) {
qd_log(http2_adaptor->protocol_log_source, QD_LOG_TRACE, "[C%"PRIu64"] nghttp2_submit_headers successful, ret_val=%"PRId32"", conn->conn_id, ret_val);
} else {
qd_log(http2_adaptor->protocol_log_source, QD_LOG_TRACE, "[C%"PRIu64"] nghttp2_submit_headers successful, new stream id=[S%"PRId32"]", conn->conn_id, ret_val);
stream_data->stream_id = ret_val;
}

//
Expand Down

0 comments on commit 01bd599

Please sign in to comment.