#include <grpc/support/port_platform.h>
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include <new>
#include <string>
#include <utility>
#include "absl/base/attributes.h"
#include "absl/status/status.h"
#include "absl/strings/cord.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "absl/types/variant.h"
#include <grpc/impl/codegen/connectivity_state.h>
#include <grpc/slice_buffer.h>
#include <grpc/status.h>
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/transport/context_list.h"
#include "src/core/ext/transport/chttp2/transport/flow_control.h"
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/ext/transport/chttp2/transport/frame_data.h"
#include "src/core/ext/transport/chttp2/transport/frame_goaway.h"
#include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h"
#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/stream_map.h"
#include "src/core/ext/transport/chttp2/transport/varint.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/bitset.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/global_config_env.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/iomgr_fwd.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/promise/poll.h"
#include "src/core/lib/resource_quota/api.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/lib/resource_quota/resource_quota.h"
#include "src/core/lib/resource_quota/trace.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_refcount.h"
#include "src/core/lib/transport/bdp_estimator.h"
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/http2_errors.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/status_conversion.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/transport/transport_impl.h"
Go to the source code of this file.
Classes | |
struct | cancel_stream_cb_args |
Namespaces | |
grpc_core | |
Macros | |
#define | CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16) |
#define | CLOSURE_BARRIER_MAY_COVER_WRITE (1 << 0) |
#define | DEFAULT_CLIENT_KEEPALIVE_TIME_MS INT_MAX |
#define | DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */ |
#define | DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024) |
#define | DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS false |
#define | DEFAULT_MAX_HEADER_LIST_SIZE (8 * 1024) |
#define | DEFAULT_MAX_PENDING_INDUCED_FRAMES 10000 |
#define | DEFAULT_MAX_PING_STRIKES 2 |
#define | DEFAULT_MAX_PINGS_BETWEEN_DATA 2 |
#define | DEFAULT_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS 300000 /* 5 minutes */ |
#define | DEFAULT_SERVER_KEEPALIVE_TIME_MS 7200000 /* 2 hours */ |
#define | DEFAULT_SERVER_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */ |
#define | KEEPALIVE_TIME_BACKOFF_MULTIPLIER 2 |
#define | MAX_CLIENT_STREAM_ID 0x7fffffffu |
#define | MAX_WINDOW 0x7fffffffu |
#define | MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024) |
Variables | |
static bool | g_default_client_keepalive_permit_without_calls |
static int | g_default_client_keepalive_time_ms |
static int | g_default_client_keepalive_timeout_ms |
static int | g_default_max_ping_strikes = DEFAULT_MAX_PING_STRIKES |
static int | g_default_max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA |
static int | g_default_min_recv_ping_interval_without_data_ms |
static bool | g_default_server_keepalive_permit_without_calls |
static int | g_default_server_keepalive_time_ms |
static int | g_default_server_keepalive_timeout_ms |
grpc_core::TraceFlag | grpc_http_trace (false, "http") |
grpc_core::TraceFlag | grpc_keepalive_trace (false, "http_keepalive") |
grpc_core::DebugOnlyTraceFlag | grpc_trace_chttp2_refcount (false, "chttp2_refcount") |
static const grpc_transport_vtable | vtable |
#define CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16) |
Definition at line 1228 of file chttp2_transport.cc.
#define CLOSURE_BARRIER_MAY_COVER_WRITE (1 << 0) |
Definition at line 1225 of file chttp2_transport.cc.
#define DEFAULT_CLIENT_KEEPALIVE_TIME_MS INT_MAX |
Definition at line 107 of file chttp2_transport.cc.
#define DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */ |
Definition at line 108 of file chttp2_transport.cc.
#define DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024) |
Definition at line 102 of file chttp2_transport.cc.
#define DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS false |
Definition at line 111 of file chttp2_transport.cc.
#define DEFAULT_MAX_HEADER_LIST_SIZE (8 * 1024) |
Definition at line 105 of file chttp2_transport.cc.
#define DEFAULT_MAX_PENDING_INDUCED_FRAMES 10000 |
Definition at line 118 of file chttp2_transport.cc.
#define DEFAULT_MAX_PING_STRIKES 2 |
Definition at line 116 of file chttp2_transport.cc.
#define DEFAULT_MAX_PINGS_BETWEEN_DATA 2 |
Definition at line 115 of file chttp2_transport.cc.
#define DEFAULT_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS 300000 /* 5 minutes */ |
Definition at line 114 of file chttp2_transport.cc.
#define DEFAULT_SERVER_KEEPALIVE_TIME_MS 7200000 /* 2 hours */ |
Definition at line 109 of file chttp2_transport.cc.
#define DEFAULT_SERVER_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */ |
Definition at line 110 of file chttp2_transport.cc.
#define KEEPALIVE_TIME_BACKOFF_MULTIPLIER 2 |
Definition at line 112 of file chttp2_transport.cc.
#define MAX_CLIENT_STREAM_ID 0x7fffffffu |
Definition at line 138 of file chttp2_transport.cc.
#define MAX_WINDOW 0x7fffffffu |
Definition at line 103 of file chttp2_transport.cc.
#define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024) |
Definition at line 104 of file chttp2_transport.cc.
|
static |
Definition at line 1230 of file chttp2_transport.cc.
|
static |
Definition at line 2127 of file chttp2_transport.cc.
Definition at line 939 of file chttp2_transport.cc.
|
static |
Definition at line 2982 of file chttp2_transport.cc.
|
static |
Definition at line 1621 of file chttp2_transport.cc.
|
static |
Definition at line 2411 of file chttp2_transport.cc.
|
static |
Definition at line 1087 of file chttp2_transport.cc.
|
static |
Definition at line 3097 of file chttp2_transport.cc.
|
static |
Definition at line 2247 of file chttp2_transport.cc.
|
static |
Definition at line 591 of file chttp2_transport.cc.
|
static |
Definition at line 459 of file chttp2_transport.cc.
|
static |
Definition at line 2913 of file chttp2_transport.cc.
|
static |
Definition at line 1313 of file chttp2_transport.cc.
|
static |
Definition at line 2602 of file chttp2_transport.cc.
|
static |
Definition at line 754 of file chttp2_transport.cc.
|
static |
Definition at line 748 of file chttp2_transport.cc.
|
static |
Definition at line 585 of file chttp2_transport.cc.
|
static |
Definition at line 573 of file chttp2_transport.cc.
|
static |
Definition at line 3012 of file chttp2_transport.cc.
|
static |
Definition at line 2417 of file chttp2_transport.cc.
|
static |
Definition at line 2647 of file chttp2_transport.cc.
|
static |
Definition at line 2654 of file chttp2_transport.cc.
|
static |
Definition at line 2838 of file chttp2_transport.cc.
|
static |
Definition at line 2845 of file chttp2_transport.cc.
|
static |
Definition at line 2156 of file chttp2_transport.cc.
|
static |
Definition at line 3113 of file chttp2_transport.cc.
GPR_GLOBAL_CONFIG_DEFINE_BOOL | ( | grpc_experimental_enable_peer_state_based_framing | , |
false | , | ||
"If | set, | ||
the max sizes of frames sent to lower layers is controlled based " "on the peer 's memory pressure which is reflected in its max http2 frame " "size." | |||
) |
void grpc_chttp2_ack_ping | ( | grpc_chttp2_transport * | t, |
uint64_t | id | ||
) |
Definition at line 1704 of file chttp2_transport.cc.
void grpc_chttp2_act_on_flowctl_action | ( | const grpc_core::chttp2::FlowControlAction & | action, |
grpc_chttp2_transport * | t, | ||
grpc_chttp2_stream * | s | ||
) |
Definition at line 2452 of file chttp2_transport.cc.
void grpc_chttp2_add_incoming_goaway | ( | grpc_chttp2_transport * | t, |
uint32_t | goaway_error, | ||
uint32_t | last_stream_id, | ||
absl::string_view | goaway_text | ||
) |
Definition at line 1099 of file chttp2_transport.cc.
void grpc_chttp2_add_ping_strike | ( | grpc_chttp2_transport * | t | ) |
Add a new ping strike to ping_recv_state.ping_strikes. If ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY with error code ENHANCE_YOUR_CALM and additional debug data resembling "too_many_pings" followed by immediately closing the connection.
Definition at line 1845 of file chttp2_transport.cc.
void grpc_chttp2_cancel_stream | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
grpc_error_handle | due_to_error | ||
) |
Definition at line 2073 of file chttp2_transport.cc.
void grpc_chttp2_complete_closure_step | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | , | ||
grpc_closure ** | pclosure, | ||
grpc_error_handle | error, | ||
const char * | desc | ||
) |
Definition at line 1247 of file chttp2_transport.cc.
void grpc_chttp2_config_default_keepalive_args | ( | grpc_channel_args * | args, |
bool | is_client | ||
) |
Set the default keepalive configurations, must only be called at initialization
Definition at line 2711 of file chttp2_transport.cc.
void grpc_chttp2_fail_pending_writes | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
grpc_error_handle | error | ||
) |
Definition at line 2170 of file chttp2_transport.cc.
void grpc_chttp2_fake_status | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
grpc_error_handle | error | ||
) |
Definition at line 2097 of file chttp2_transport.cc.
void grpc_chttp2_initiate_write | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_initiate_write_reason | reason | ||
) |
Transport writing call flow: grpc_chttp2_initiate_write() is called anywhere that we know bytes need to go out on the wire. If no other write has been started, a task is enqueued onto our workqueue. When that task executes, it obtains the global lock, and gathers the data to write. The global lock is dropped and we do the syscall to write. After writing, a follow-up check is made to see if another round of writing should be performed.
The actual call chain is documented in the implementation of this function.
Definition at line 891 of file chttp2_transport.cc.
const char* grpc_chttp2_initiate_write_reason_string | ( | grpc_chttp2_initiate_write_reason | reason | ) |
Definition at line 3046 of file chttp2_transport.cc.
void grpc_chttp2_mark_stream_closed | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
int | close_reads, | ||
int | close_writes, | ||
grpc_error_handle | error | ||
) |
Definition at line 2193 of file chttp2_transport.cc.
void grpc_chttp2_mark_stream_writable | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s | ||
) |
add a ref to the stream and add it to the writable list; ref will be dropped in writing.c
Definition at line 931 of file chttp2_transport.cc.
void grpc_chttp2_maybe_complete_recv_initial_metadata | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s | ||
) |
Definition at line 1934 of file chttp2_transport.cc.
void grpc_chttp2_maybe_complete_recv_message | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s | ||
) |
Definition at line 1956 of file chttp2_transport.cc.
void grpc_chttp2_maybe_complete_recv_trailing_metadata | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s | ||
) |
Definition at line 2025 of file chttp2_transport.cc.
grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream | ( | grpc_chttp2_transport * | t, |
uint32_t | id | ||
) |
Definition at line 766 of file chttp2_transport.cc.
void grpc_chttp2_reset_ping_clock | ( | grpc_chttp2_transport * | t | ) |
Resets ping clock. Should be called when flushing window updates, initial/trailing metadata or data frames. For a server, it resets the number of ping strikes and the last_ping_recv_time. For a ping sender, it resets pings_before_data_required.
Definition at line 1861 of file chttp2_transport.cc.
void grpc_chttp2_retry_initiate_ping | ( | void * | tp, |
grpc_error_handle | error | ||
) |
Definition at line 1688 of file chttp2_transport.cc.
void grpc_chttp2_stream_ref | ( | grpc_chttp2_stream * | s, |
const char * | reason | ||
) |
Definition at line 656 of file chttp2_transport.cc.
void grpc_chttp2_stream_unref | ( | grpc_chttp2_stream * | s, |
const char * | reason | ||
) |
Definition at line 659 of file chttp2_transport.cc.
grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode> grpc_chttp2_transport_get_socket_node | ( | grpc_transport * | transport | ) |
Definition at line 3116 of file chttp2_transport.cc.
void grpc_chttp2_transport_start_reading | ( | grpc_transport * | transport, |
grpc_slice_buffer * | read_buffer, | ||
grpc_closure * | notify_on_receive_settings, | ||
grpc_closure * | notify_on_close | ||
) |
Takes ownership of read_buffer, which (if non-NULL) contains leftover bytes previously read from the endpoint (e.g., by handshakers). If non-null, notify_on_receive_settings will be scheduled when HTTP/2 settings are received from the peer.
Definition at line 3128 of file chttp2_transport.cc.
grpc_transport* grpc_create_chttp2_transport | ( | const grpc_channel_args * | channel_args, |
grpc_endpoint * | ep, | ||
bool | is_client | ||
) |
Creates a CHTTP2 Transport. This takes ownership of a resource_user ref from the caller; if the caller still needs the resource_user after creating a transport, the caller must take another ref.
Definition at line 3122 of file chttp2_transport.cc.
|
static |
Definition at line 819 of file chttp2_transport.cc.
|
static |
Definition at line 2770 of file chttp2_transport.cc.
|
static |
Definition at line 2777 of file chttp2_transport.cc.
|
static |
Definition at line 467 of file chttp2_transport.cc.
|
static |
Definition at line 739 of file chttp2_transport.cc.
|
static |
Definition at line 433 of file chttp2_transport.cc.
|
static |
Definition at line 2876 of file chttp2_transport.cc.
|
static |
Definition at line 2884 of file chttp2_transport.cc.
|
static |
Definition at line 1318 of file chttp2_transport.cc.
|
static |
Definition at line 1170 of file chttp2_transport.cc.
|
static |
Definition at line 2685 of file chttp2_transport.cc.
|
static |
Definition at line 2693 of file chttp2_transport.cc.
|
static |
Definition at line 1235 of file chttp2_transport.cc.
|
static |
Definition at line 1590 of file chttp2_transport.cc.
|
static |
Definition at line 1327 of file chttp2_transport.cc.
|
static |
Definition at line 1917 of file chttp2_transport.cc.
|
static |
Definition at line 1870 of file chttp2_transport.cc.
|
static |
Definition at line 2942 of file chttp2_transport.cc.
|
static |
Definition at line 2962 of file chttp2_transport.cc.
|
static |
Definition at line 1071 of file chttp2_transport.cc.
|
static |
Definition at line 2505 of file chttp2_transport.cc.
|
static |
Definition at line 2512 of file chttp2_transport.cc.
|
static |
Definition at line 288 of file chttp2_transport.cc.
|
static |
Definition at line 2139 of file chttp2_transport.cc.
|
static |
Definition at line 2044 of file chttp2_transport.cc.
|
static |
Definition at line 1695 of file chttp2_transport.cc.
void schedule_bdp_ping_locked | ( | grpc_chttp2_transport * | t | ) |
Definition at line 2612 of file chttp2_transport.cc.
|
static |
Definition at line 1815 of file chttp2_transport.cc.
|
static |
Definition at line 1652 of file chttp2_transport.cc.
|
static |
Definition at line 1633 of file chttp2_transport.cc.
|
static |
Definition at line 2926 of file chttp2_transport.cc.
|
static |
Definition at line 2932 of file chttp2_transport.cc.
|
static |
Definition at line 796 of file chttp2_transport.cc.
|
static |
Definition at line 2623 of file chttp2_transport.cc.
|
static |
Definition at line 2630 of file chttp2_transport.cc.
|
static |
Definition at line 2810 of file chttp2_transport.cc.
|
static |
Definition at line 2817 of file chttp2_transport.cc.
|
static |
Definition at line 2476 of file chttp2_transport.cc.
|
static |
Definition at line 2437 of file chttp2_transport.cc.
|
static |
Definition at line 987 of file chttp2_transport.cc.
|
static |
Definition at line 947 of file chttp2_transport.cc.
|
static |
Definition at line 1011 of file chttp2_transport.cc.
|
static |
Definition at line 1020 of file chttp2_transport.cc.
|
static |
Definition at line 784 of file chttp2_transport.cc.
|
static |
Definition at line 128 of file chttp2_transport.cc.
|
static |
Definition at line 120 of file chttp2_transport.cc.
|
static |
Definition at line 122 of file chttp2_transport.cc.
|
static |
Definition at line 136 of file chttp2_transport.cc.
|
static |
Definition at line 135 of file chttp2_transport.cc.
|
static |
Definition at line 133 of file chttp2_transport.cc.
|
static |
Definition at line 130 of file chttp2_transport.cc.
|
static |
Definition at line 124 of file chttp2_transport.cc.
|
static |
Definition at line 126 of file chttp2_transport.cc.
grpc_core::TraceFlag grpc_http_trace(false, "http") |
grpc_core::TraceFlag grpc_keepalive_trace(false, "http_keepalive") |
grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false, "chttp2_refcount") |
|
static |
Definition at line 3101 of file chttp2_transport.cc.