Rename nghttp2_session_fail_session as nghttp2_session_terminate_session

This commit is contained in:
Tatsuhiro Tsujikawa 2013-12-26 00:23:07 +09:00
parent a14cfa59df
commit 9cb8754d09
10 changed files with 40 additions and 29 deletions

View File

@ -250,7 +250,7 @@ static int on_stream_close_callback(nghttp2_session *session,
if(session_data->stream_data->stream_id == stream_id) {
fprintf(stderr, "Stream %d closed with error_code=%d\n",
stream_id, error_code);
rv = nghttp2_session_fail_session(session, NGHTTP2_NO_ERROR);
rv = nghttp2_session_terminate_session(session, NGHTTP2_NO_ERROR);
if(rv != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}

View File

@ -1687,7 +1687,15 @@ int32_t nghttp2_session_get_effective_local_window_size
/**
* @function
*
* Submits GOAWAY frame with the given |error_code|.
* Signals the session so that the connection should be terminated.
*
* GOAWAY frame with the given |error_code| will be submitted if it
* has not been transmitted. After the transmission, both
* `nghttp2_session_want_read()` and `nghttp2_session_want_write()`
* return 0. If GOAWAY frame has already transmitted at the time when
* this function is invoked, `nghttp2_session_want_read()` and
* `nghttp2_session_want_write()` returns 0 immediately after this
* function succeeds.
*
* This function should be called when the connection should be
* terminated after sending GOAWAY. If the remaining streams should be
@ -1699,8 +1707,8 @@ int32_t nghttp2_session_get_effective_local_window_size
* :enum:`NGHTTP2_ERR_NOMEM`
* Out of memory.
*/
int nghttp2_session_fail_session(nghttp2_session *session,
nghttp2_error_code error_code);
int nghttp2_session_terminate_session(nghttp2_session *session,
nghttp2_error_code error_code);
/**
* @function

View File

@ -80,8 +80,8 @@ static int32_t nghttp2_pushed_stream_pri(nghttp2_stream *stream)
(int32_t)NGHTTP2_PRI_LOWEST : stream->pri + 1;
}
int nghttp2_session_fail_session(nghttp2_session *session,
nghttp2_error_code error_code)
int nghttp2_session_terminate_session(nghttp2_session *session,
nghttp2_error_code error_code)
{
if(session->goaway_flags & NGHTTP2_GOAWAY_FAIL_ON_SEND) {
return 0;
@ -1674,8 +1674,8 @@ int nghttp2_session_send(nghttp2_session *session)
if(framebuflen == NGHTTP2_ERR_HEADER_COMP) {
/* If header compression error occurred, should terminiate
connection. */
framebuflen = nghttp2_session_fail_session(session,
NGHTTP2_INTERNAL_ERROR);
framebuflen = nghttp2_session_terminate_session
(session, NGHTTP2_INTERNAL_ERROR);
}
if(nghttp2_is_fatal(framebuflen)) {
return framebuflen;
@ -1843,7 +1843,7 @@ static int nghttp2_session_handle_parse_error(nghttp2_session *session,
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
return nghttp2_session_fail_session(session, error_code);
return nghttp2_session_terminate_session(session, error_code);
}
static int nghttp2_session_handle_invalid_stream
@ -1879,7 +1879,7 @@ static int nghttp2_session_handle_invalid_connection
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
return nghttp2_session_fail_session(session, error_code);
return nghttp2_session_terminate_session(session, error_code);
}
int nghttp2_session_on_request_headers_received(nghttp2_session *session,
@ -2984,7 +2984,7 @@ int nghttp2_session_on_data_received(nghttp2_session *session,
/* The spec says that if a DATA frame is received whose stream ID
is 0, the recipient MUST respond with a connection error of
type PROTOCOL_ERROR. */
return nghttp2_session_fail_session(session, NGHTTP2_PROTOCOL_ERROR);
return nghttp2_session_terminate_session(session, NGHTTP2_PROTOCOL_ERROR);
}
stream = nghttp2_session_get_stream(session, stream_id);
if(!stream) {
@ -2995,7 +2995,7 @@ int nghttp2_session_on_data_received(nghttp2_session *session,
}
if(stream->state == NGHTTP2_STREAM_RESERVED) {
/* reserved and receiving DATA is connection error */
return nghttp2_session_fail_session(session, NGHTTP2_PROTOCOL_ERROR);
return nghttp2_session_terminate_session(session, NGHTTP2_PROTOCOL_ERROR);
}
if(stream->shut_flags & NGHTTP2_SHUT_RD) {
/* half closed (remote): from the spec:
@ -3012,7 +3012,8 @@ int nghttp2_session_on_data_received(nghttp2_session *session,
is broken, it may send lots of DATA frames and we will send
RST_STREAM for each of them, which is bad. So we just close
the connection here. */
return nghttp2_session_fail_session(session, NGHTTP2_PROTOCOL_ERROR);
return nghttp2_session_terminate_session(session,
NGHTTP2_PROTOCOL_ERROR);
}
return 0;
}
@ -3032,7 +3033,8 @@ int nghttp2_session_on_data_received(nghttp2_session *session,
peer is broken, it may send lots of DATA frames and we will
send RST_STREAM for each of them, which is bad. So we just
close the connection here. */
return nghttp2_session_fail_session(session, NGHTTP2_PROTOCOL_ERROR);
return nghttp2_session_terminate_session(session,
NGHTTP2_PROTOCOL_ERROR);
}
} else if(stream->state != NGHTTP2_STREAM_CLOSING) {
/* It is OK if this is remote peer initiated stream and we did
@ -3160,7 +3162,8 @@ static int nghttp2_session_update_recv_connection_window_size
rv = adjust_recv_window_size(&session->recv_window_size, delta_size,
session->local_window_size);
if(rv != 0) {
return nghttp2_session_fail_session(session, NGHTTP2_FLOW_CONTROL_ERROR);
return nghttp2_session_terminate_session(session,
NGHTTP2_FLOW_CONTROL_ERROR);
}
if(!(session->opt_flags &
NGHTTP2_OPTMASK_NO_AUTO_CONNECTION_WINDOW_UPDATE)) {

View File

@ -352,7 +352,7 @@ namespace {
void settings_timeout_cb(evutil_socket_t fd, short what, void *arg)
{
auto hd = reinterpret_cast<Http2Handler*>(arg);
hd->fail_session(NGHTTP2_SETTINGS_TIMEOUT);
hd->terminate_session(NGHTTP2_SETTINGS_TIMEOUT);
hd->on_write();
}
} // namespace
@ -581,9 +581,9 @@ void Http2Handler::remove_settings_timer()
}
}
void Http2Handler::fail_session(nghttp2_error_code error_code)
void Http2Handler::terminate_session(nghttp2_error_code error_code)
{
nghttp2_session_fail_session(session_, error_code);
nghttp2_session_terminate_session(session_, error_code);
}
namespace {

View File

@ -119,7 +119,7 @@ public:
size_t get_left_connhd_len() const;
void set_left_connhd_len(size_t left);
void remove_settings_timer();
void fail_session(nghttp2_error_code error_code);
void terminate_session(nghttp2_error_code error_code);
private:
std::map<int32_t, std::unique_ptr<Request>> id2req_;
int64_t session_id_;

View File

@ -1084,7 +1084,7 @@ namespace {
void settings_timeout_cb(evutil_socket_t fd, short what, void *arg)
{
auto client = get_session(arg);
nghttp2_session_fail_session(client->session, NGHTTP2_SETTINGS_TIMEOUT);
nghttp2_session_terminate_session(client->session, NGHTTP2_SETTINGS_TIMEOUT);
client->on_write();
}
} // namespace
@ -1181,7 +1181,7 @@ int on_stream_close_callback
(*itr).second->record_complete_time();
++client->complete;
if(client->all_requests_processed()) {
nghttp2_session_fail_session(session, NGHTTP2_NO_ERROR);
nghttp2_session_terminate_session(session, NGHTTP2_NO_ERROR);
}
}
return 0;

View File

@ -760,7 +760,7 @@ void settings_timeout_cb(evutil_socket_t fd, short what, void *arg)
{
auto http2session = reinterpret_cast<Http2Session*>(arg);
SSLOG(INFO, http2session) << "SETTINGS timeout";
if(http2session->fail_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) {
if(http2session->terminate_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) {
http2session->disconnect();
return;
}
@ -1290,10 +1290,10 @@ void Http2Session::set_state(int state)
state_ = state;
}
int Http2Session::fail_session(nghttp2_error_code error_code)
int Http2Session::terminate_session(nghttp2_error_code error_code)
{
int rv;
rv = nghttp2_session_fail_session(session_, error_code);
rv = nghttp2_session_terminate_session(session_, error_code);
if(rv != 0) {
return -1;
}

View File

@ -74,7 +74,7 @@ public:
// |dconn|.
int submit_window_update(Http2DownstreamConnection *dconn, int32_t amount);
int fail_session(nghttp2_error_code error_code);
int terminate_session(nghttp2_error_code error_code);
nghttp2_session* get_session() const;

View File

@ -177,7 +177,7 @@ void settings_timeout_cb(evutil_socket_t fd, short what, void *arg)
{
auto upstream = reinterpret_cast<Http2Upstream*>(arg);
ULOG(INFO, upstream) << "SETTINGS timeout";
if(upstream->fail_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) {
if(upstream->terminate_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) {
delete upstream->get_client_handler();
return;
}
@ -813,10 +813,10 @@ int Http2Upstream::window_update(Downstream *downstream,
return 0;
}
int Http2Upstream::fail_session(nghttp2_error_code error_code)
int Http2Upstream::terminate_session(nghttp2_error_code error_code)
{
int rv;
rv = nghttp2_session_fail_session(session_, error_code);
rv = nghttp2_session_terminate_session(session_, error_code);
if(rv != 0) {
return -1;
}

View File

@ -61,7 +61,7 @@ public:
// To send WINDOW_UPDATE for a connection, specify nullptr to
// |downstream|.
int window_update(Downstream *downstream, int32_t window_size_increment);
int fail_session(nghttp2_error_code error_code);
int terminate_session(nghttp2_error_code error_code);
int error_reply(Downstream *downstream, unsigned int status_code);
virtual void pause_read(IOCtrlReason reason);