Remove adjust_priority_callback
Since we have stream ID immediately available from nghttp2_submit_*, we don't need adjust_priority_callback.
This commit is contained in:
parent
e8de437d5c
commit
d2890dfb91
|
@ -1415,37 +1415,6 @@ typedef ssize_t (*nghttp2_select_padding_callback)
|
|||
size_t max_payloadlen,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* @functypedef
|
||||
*
|
||||
* Callback function invoked to adjust priority value for request
|
||||
* HEADERS. This callback is called only for request HEADERS (which
|
||||
* means, `frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat ==
|
||||
* NGHTTP2_HCAT_REQUEST` hold) and before
|
||||
* :type:`nghttp2_before_frame_send_callback()`. The application can
|
||||
* adjust priority value |pri_spec|. Initially, |pri_spec| is filled
|
||||
* with the current priority value, which is equal to
|
||||
* `frame->headers.pri_spec`. If the application doesn't alter
|
||||
* priority value, just return 0 without updating |pri_spec|.
|
||||
*
|
||||
* Since the application doesn't know stream ID when it submits
|
||||
* requests, it may not be able to add correct priority value to
|
||||
* HEADERS frame and forced to use follwing PRIORITY frame. The
|
||||
* purpose of this callback is give the chance to the application to
|
||||
* adjust priority value with the latest information it has just
|
||||
* before transmission so that correct priority is included in HEADERS
|
||||
* frame and it doesn't have to send additional PRIORITY frame.
|
||||
*
|
||||
* Returning :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will make
|
||||
* `nghttp2_session_send()` function immediately return
|
||||
* :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.
|
||||
*/
|
||||
typedef int (*nghttp2_adjust_priority_callback)
|
||||
(nghttp2_session *session,
|
||||
const nghttp2_frame *frame,
|
||||
nghttp2_priority_spec *pri_spec,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* @struct
|
||||
*
|
||||
|
@ -1519,11 +1488,6 @@ typedef struct {
|
|||
* frame.
|
||||
*/
|
||||
nghttp2_select_padding_callback select_padding_callback;
|
||||
/**
|
||||
* Callback function invoked to adjust priority value just before
|
||||
* request HEADERS is serialized to the wire format.
|
||||
*/
|
||||
nghttp2_adjust_priority_callback adjust_priority_callback;
|
||||
} nghttp2_session_callbacks;
|
||||
|
||||
struct nghttp2_option;
|
||||
|
@ -1730,20 +1694,17 @@ void nghttp2_session_del(nghttp2_session *session);
|
|||
* are not met (e.g., request HEADERS cannot be sent after GOAWAY),
|
||||
* :member:`nghttp2_session_callbacks.on_frame_not_send_callback`
|
||||
* is invoked. Abort the following steps.
|
||||
* 4. If the frame is request HEADERS,
|
||||
* :member:`nghttp2_session_callbacks.adjust_priority_callback` is
|
||||
* invoked.
|
||||
* 5. If the frame is HEADERS, PUSH_PROMISE or DATA,
|
||||
* 4. If the frame is HEADERS, PUSH_PROMISE or DATA,
|
||||
* :member:`nghttp2_session_callbacks.select_padding_callback` is
|
||||
* invoked.
|
||||
* 6. If the frame is request HEADERS, the stream is opened here.
|
||||
* 7. :member:`nghttp2_session_callbacks.before_frame_send_callback` is
|
||||
* 5. If the frame is request HEADERS, the stream is opened here.
|
||||
* 6. :member:`nghttp2_session_callbacks.before_frame_send_callback` is
|
||||
* invoked.
|
||||
* 8. :member:`nghttp2_session_callbacks.send_callback` is invoked one
|
||||
* 7. :member:`nghttp2_session_callbacks.send_callback` is invoked one
|
||||
* or more times to send the frame.
|
||||
* 9. :member:`nghttp2_session_callbacks.on_frame_send_callback` is
|
||||
* 8. :member:`nghttp2_session_callbacks.on_frame_send_callback` is
|
||||
* invoked.
|
||||
* 10. If the transmission of the frame triggers closure of the stream,
|
||||
* 9. If the transmission of the frame triggers closure of the stream,
|
||||
* the stream is closed and
|
||||
* :member:`nghttp2_session_callbacks.on_stream_close_callback` is
|
||||
* invoked.
|
||||
|
|
|
@ -1494,43 +1494,6 @@ static int session_consider_blocked(nghttp2_session *session,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int session_call_adjust_priority(nghttp2_session *session,
|
||||
nghttp2_frame *frame,
|
||||
nghttp2_stream *stream)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if(session->callbacks.adjust_priority_callback) {
|
||||
nghttp2_priority_spec pri_spec;
|
||||
|
||||
pri_spec = frame->headers.pri_spec;
|
||||
|
||||
rv = session->callbacks.adjust_priority_callback(session, frame,
|
||||
&pri_spec,
|
||||
session->user_data);
|
||||
|
||||
if(rv != 0) {
|
||||
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||
}
|
||||
|
||||
frame->headers.pri_spec = pri_spec;
|
||||
|
||||
if(nghttp2_priority_spec_check_default(&pri_spec)) {
|
||||
rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec);
|
||||
|
||||
if(nghttp2_is_fatal(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
frame->hd.flags &= ~NGHTTP2_FLAG_PRIORITY;
|
||||
} else {
|
||||
frame->hd.flags |= NGHTTP2_FLAG_PRIORITY;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function serializes frame for transmission.
|
||||
*
|
||||
|
@ -1553,7 +1516,6 @@ static int nghttp2_session_prep_frame(nghttp2_session *session,
|
|||
aux_data = (nghttp2_headers_aux_data*)item->aux_data;
|
||||
|
||||
if(frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
|
||||
nghttp2_priority_spec pri_spec_default;
|
||||
nghttp2_stream *stream;
|
||||
|
||||
/* initial HEADERS, which opens stream */
|
||||
|
@ -1563,14 +1525,10 @@ static int nghttp2_session_prep_frame(nghttp2_session *session,
|
|||
return rv;
|
||||
}
|
||||
|
||||
/* We first open strea with default priority. This is because
|
||||
priority may be adjusted in callback. */
|
||||
nghttp2_priority_spec_default_init(&pri_spec_default);
|
||||
|
||||
stream = nghttp2_session_open_stream
|
||||
(session, frame->hd.stream_id,
|
||||
NGHTTP2_STREAM_FLAG_NONE,
|
||||
&pri_spec_default,
|
||||
&frame->headers.pri_spec,
|
||||
NGHTTP2_STREAM_INITIAL,
|
||||
aux_data ? aux_data->stream_user_data : NULL);
|
||||
|
||||
|
@ -1578,14 +1536,6 @@ static int nghttp2_session_prep_frame(nghttp2_session *session,
|
|||
return NGHTTP2_ERR_NOMEM;
|
||||
}
|
||||
|
||||
/* We need to call this after stream was opened so that we can
|
||||
use nghttp2_session_get_stream_user_data() */
|
||||
rv = session_call_adjust_priority(session, frame, stream);
|
||||
|
||||
if(nghttp2_is_fatal(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
} else if(nghttp2_session_predicate_push_response_headers_send
|
||||
(session, frame->hd.stream_id) == 0) {
|
||||
frame->headers.cat = NGHTTP2_HCAT_PUSH_RESPONSE;
|
||||
|
@ -1606,16 +1556,7 @@ static int nghttp2_session_prep_frame(nghttp2_session *session,
|
|||
&session->hd_deflater);
|
||||
|
||||
if(framerv < 0) {
|
||||
if(!nghttp2_is_fatal(framerv)) {
|
||||
rv = nghttp2_session_close_stream(session, frame->hd.stream_id,
|
||||
NGHTTP2_NO_ERROR);
|
||||
|
||||
if(nghttp2_is_fatal(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return framerv;
|
||||
goto close_stream_return;
|
||||
}
|
||||
|
||||
DEBUGF(fprintf(stderr,
|
||||
|
@ -1623,8 +1564,9 @@ static int nghttp2_session_prep_frame(nghttp2_session *session,
|
|||
nghttp2_bufs_len(&session->aob.framebufs)));
|
||||
|
||||
framerv = session_headers_add_pad(session, frame);
|
||||
|
||||
if(framerv < 0) {
|
||||
return framerv;
|
||||
goto close_stream_return;
|
||||
}
|
||||
|
||||
if(frame->headers.cat == NGHTTP2_HCAT_PUSH_RESPONSE) {
|
||||
|
@ -1639,6 +1581,20 @@ static int nghttp2_session_prep_frame(nghttp2_session *session,
|
|||
nghttp2_bufs_len(&session->aob.framebufs)));
|
||||
|
||||
break;
|
||||
|
||||
close_stream_return:
|
||||
|
||||
if(frame->headers.cat == NGHTTP2_HCAT_REQUEST &&
|
||||
!nghttp2_is_fatal(framerv)) {
|
||||
rv = nghttp2_session_close_stream(session, frame->hd.stream_id,
|
||||
NGHTTP2_NO_ERROR);
|
||||
|
||||
if(nghttp2_is_fatal(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return framerv;
|
||||
}
|
||||
case NGHTTP2_PRIORITY: {
|
||||
rv = nghttp2_session_predicate_priority_send
|
||||
|
|
Loading…
Reference in New Issue