GRPC C++
1.39.1
|
#include <grpc/support/port_platform.h>
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "absl/strings/str_format.h"
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "src/core/ext/transport/chttp2/transport/context_list.h"
#include "src/core/ext/transport/chttp2/transport/frame_data.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/varint.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/http2_errors.h"
#include "src/core/lib/transport/static_metadata.h"
#include "src/core/lib/transport/status_conversion.h"
#include "src/core/lib/transport/timeout_encoding.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/transport/transport_impl.h"
#include "src/core/lib/uri/uri_parser.h"
Data Structures | |
struct | cancel_stream_cb_args |
Namespaces | |
grpc_core | |
Round Robin Policy. | |
Macros | |
#define | DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024) |
#define | MAX_WINDOW 0x7fffffffu |
#define | MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024) |
#define | DEFAULT_MAX_HEADER_LIST_SIZE (8 * 1024) |
#define | DEFAULT_CLIENT_KEEPALIVE_TIME_MS INT_MAX |
#define | DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */ |
#define | DEFAULT_SERVER_KEEPALIVE_TIME_MS 7200000 /* 2 hours */ |
#define | DEFAULT_SERVER_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */ |
#define | DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS false |
#define | KEEPALIVE_TIME_BACKOFF_MULTIPLIER 2 |
#define | DEFAULT_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS 300000 /* 5 minutes */ |
#define | DEFAULT_MAX_PINGS_BETWEEN_DATA 2 |
#define | DEFAULT_MAX_PING_STRIKES 2 |
#define | DEFAULT_MAX_PENDING_INDUCED_FRAMES 10000 |
#define | MAX_CLIENT_STREAM_ID 0x7fffffffu |
#define | CLOSURE_BARRIER_MAY_COVER_WRITE (1 << 0) |
#define | CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16) |
Variables | |
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") |
bool | g_flow_control_enabled = true |
#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) |
void grpc_chttp2_ack_ping | ( | grpc_chttp2_transport * | t, |
uint64_t | id | ||
) |
void grpc_chttp2_act_on_flowctl_action | ( | const grpc_core::chttp2::FlowControlAction & | action, |
grpc_chttp2_transport * | t, | ||
grpc_chttp2_stream * | s | ||
) |
void grpc_chttp2_add_incoming_goaway | ( | grpc_chttp2_transport * | t, |
uint32_t | goaway_error, | ||
uint32_t | last_stream_id, | ||
const grpc_slice & | goaway_text | ||
) |
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.
void grpc_chttp2_cancel_stream | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
grpc_error_handle | due_to_error | ||
) |
void grpc_chttp2_complete_closure_step | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
grpc_closure ** | pclosure, | ||
grpc_error_handle | error, | ||
const char * | desc | ||
) |
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.
void grpc_chttp2_fail_pending_writes | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
grpc_error_handle | error | ||
) |
void grpc_chttp2_fake_status | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
grpc_error_handle | error | ||
) |
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.
const char* grpc_chttp2_initiate_write_reason_string | ( | grpc_chttp2_initiate_write_reason | reason | ) |
void grpc_chttp2_mark_stream_closed | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s, | ||
int | close_reads, | ||
int | close_writes, | ||
grpc_error_handle | error | ||
) |
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
void grpc_chttp2_maybe_complete_recv_initial_metadata | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s | ||
) |
void grpc_chttp2_maybe_complete_recv_message | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s | ||
) |
void grpc_chttp2_maybe_complete_recv_trailing_metadata | ( | grpc_chttp2_transport * | t, |
grpc_chttp2_stream * | s | ||
) |
grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream | ( | grpc_chttp2_transport * | t, |
uint32_t | id | ||
) |
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.
void grpc_chttp2_retry_initiate_ping | ( | void * | tp, |
grpc_error_handle | error | ||
) |
void grpc_chttp2_stream_ref | ( | grpc_chttp2_stream * | s, |
const char * | reason | ||
) |
void grpc_chttp2_stream_unref | ( | grpc_chttp2_stream * | s, |
const char * | reason | ||
) |
grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode> grpc_chttp2_transport_get_socket_node | ( | grpc_transport * | transport | ) |
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.
grpc_transport* grpc_create_chttp2_transport | ( | const grpc_channel_args * | channel_args, |
grpc_endpoint * | ep, | ||
bool | is_client, | ||
grpc_resource_user * | resource_user | ||
) |
void schedule_bdp_ping_locked | ( | grpc_chttp2_transport * | t | ) |
bool g_flow_control_enabled = true |
grpc_core::TraceFlag grpc_http_trace(false, "http") | ( | false | , |
"http" | |||
) |
grpc_core::TraceFlag grpc_keepalive_trace(false, "http_keepalive") | ( | false | , |
"http_keepalive" | |||
) |
grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false, "chttp2_refcount") | ( | false | , |
"chttp2_refcount" | |||
) |