aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/grpc/impl/codegen/port_platform.h13
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.cc6
-rw-r--r--src/core/ext/filters/client_channel/channel_connectivity.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc8
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc6
-rw-r--r--src/core/ext/filters/http/client/http_client_filter.cc10
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.cc14
-rw-r--r--src/core/ext/filters/http/server/http_server_filter.cc10
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_filter.cc10
-rw-r--r--src/core/ext/filters/max_age/max_age_filter.cc6
-rw-r--r--src/core/ext/filters/message_size/message_size_filter.cc10
-rw-r--r--src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc6
-rw-r--r--src/core/lib/iomgr/tcp_posix.cc10
-rw-r--r--src/core/lib/iomgr/tcp_uv.cc30
-rw-r--r--src/core/lib/security/transport/client_auth_filter.cc10
-rw-r--r--src/core/lib/security/transport/server_auth_filter.cc14
-rw-r--r--src/core/lib/surface/server.cc24
-rw-r--r--tools/bazel.rc1
21 files changed, 139 insertions, 73 deletions
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index f4bc3eb3e0..e6bee73ef1 100644
--- a/include/grpc/impl/codegen/port_platform.h
+++ b/include/grpc/impl/codegen/port_platform.h
@@ -195,12 +195,25 @@
#define GPR_PTHREAD_TLS 1
#else /* __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7 */
#define GPR_CPU_POSIX 1
+/* TODO(vjpai): there is a reported issue in bazel build for Mac where __thread
+ in a header is currently not working (bazelbuild/bazel#4341). Remove
+ the following conditional and use GPR_GCC_TLS when that is fixed */
+#ifndef GRPC_BAZEL_BUILD
#define GPR_GCC_TLS 1
+#else /* GRPC_BAZEL_BUILD */
+#define GPR_PTHREAD_TLS 1
+#endif /* GRPC_BAZEL_BUILD */
#define GPR_APPLE_PTHREAD_NAME 1
#endif
#else /* __MAC_OS_X_VERSION_MIN_REQUIRED */
#define GPR_CPU_POSIX 1
+/* TODO(vjpai): Remove the following conditional and use only GPR_GCC_TLS
+ when bazelbuild/bazel#4341 is fixed */
+#ifndef GRPC_BAZEL_BUILD
#define GPR_GCC_TLS 1
+#else /* GRPC_BAZEL_BUILD */
+#define GPR_PTHREAD_TLS 1
+#endif /* GRPC_BAZEL_BUILD */
#endif
#define GPR_POSIX_CRASH_HANDLER 1
#endif
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc
index bfc549e709..4ee5e9c109 100644
--- a/src/core/ext/filters/client_channel/backup_poller.cc
+++ b/src/core/ext/filters/client_channel/backup_poller.cc
@@ -33,7 +33,8 @@
#define DEFAULT_POLL_INTERVAL_MS 5000
-typedef struct backup_poller {
+namespace {
+struct backup_poller {
grpc_timer polling_timer;
grpc_closure run_poller_closure;
grpc_closure shutdown_closure;
@@ -42,7 +43,8 @@ typedef struct backup_poller {
bool shutting_down; // guarded by pollset_mu
gpr_refcount refs;
gpr_refcount shutdown_refs;
-} backup_poller;
+};
+} // namespace
static gpr_once g_once = GPR_ONCE_INIT;
static gpr_mu g_poller_mu;
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc
index 20693ba419..a827aa30ec 100644
--- a/src/core/ext/filters/client_channel/channel_connectivity.cc
+++ b/src/core/ext/filters/client_channel/channel_connectivity.cc
@@ -58,7 +58,8 @@ typedef enum {
CALLING_BACK_AND_FINISHED,
} callback_phase;
-typedef struct {
+namespace {
+struct state_watcher {
gpr_mu mu;
callback_phase phase;
grpc_closure on_complete;
@@ -71,7 +72,8 @@ typedef struct {
grpc_channel* channel;
grpc_error* error;
void* tag;
-} state_watcher;
+};
+} // namespace
static void delete_state_watcher(state_watcher* w) {
grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
index 3eedb08ecc..1708d81e61 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
@@ -32,7 +32,8 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
static void destroy_channel_elem(grpc_channel_element* elem) {}
-typedef struct {
+namespace {
+struct call_data {
// Stats object to update.
grpc_grpclb_client_stats* client_stats;
// State for intercepting send_initial_metadata.
@@ -43,7 +44,8 @@ typedef struct {
grpc_closure recv_initial_metadata_ready;
grpc_closure* original_recv_initial_metadata_ready;
bool recv_initial_metadata_succeeded;
-} call_data;
+};
+} // namespace
static void on_complete_for_send(void* arg, grpc_error* error) {
call_data* calld = (call_data*)arg;
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
index ba4e90d4c2..f2bb409680 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
@@ -226,6 +226,7 @@ static void wrapped_rr_closure(void* arg, grpc_error* error) {
gpr_free(wc_arg->free_when_done);
}
+namespace {
/* Linked list of pending pick requests. It stores all information needed to
* eventually call (Round Robin's) pick() on them. They mainly stay pending
* waiting for the RR policy to be created/updated.
@@ -234,7 +235,7 @@ static void wrapped_rr_closure(void* arg, grpc_error* error) {
* (in \a wrapped_on_complete and \a wrapped_on_complete_arg). This is needed in
* order to correctly unref the RR policy instance upon completion of the pick.
* See \a wrapped_rr_closure for details. */
-typedef struct pending_pick {
+struct pending_pick {
struct pending_pick* next;
/* original pick()'s arguments */
@@ -246,7 +247,8 @@ typedef struct pending_pick {
/* args for wrapped_on_complete */
wrapped_rr_closure_arg wrapped_on_complete_arg;
-} pending_pick;
+};
+} // namespace
static void add_pending_pick(pending_pick** root,
const grpc_lb_policy_pick_args* pick_args,
diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
index 0861261359..9ff40aa53c 100644
--- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
@@ -31,12 +31,14 @@
grpc_core::TraceFlag grpc_lb_pick_first_trace(false, "pick_first");
-typedef struct pending_pick {
+namespace {
+struct pending_pick {
struct pending_pick* next;
uint32_t initial_metadata_flags;
grpc_connected_subchannel** target;
grpc_closure* on_complete;
-} pending_pick;
+};
+} // namespace
typedef struct {
/** base policy: must be first */
diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
index b0c84017df..a964af0627 100644
--- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
@@ -41,11 +41,12 @@
grpc_core::TraceFlag grpc_lb_round_robin_trace(false, "round_robin");
+namespace {
/** List of entities waiting for a pick.
*
* Once a pick is available, \a target is updated and \a on_complete called. */
-typedef struct pending_pick {
- struct pending_pick* next;
+struct pending_pick {
+ pending_pick* next;
/* output argument where to store the pick()ed user_data. It'll be NULL if no
* such data is present or there's an error (the definite test for errors is
@@ -62,7 +63,8 @@ typedef struct pending_pick {
/* to be invoked once the pick() has completed (regardless of success) */
grpc_closure* on_complete;
-} pending_pick;
+};
+} // namespace
typedef struct round_robin_lb_policy {
/** base policy: must be first */
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index f07394d29b..a604c55c58 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -59,11 +59,13 @@
((grpc_connected_subchannel*)(gpr_atm_##barrier##_load( \
&(subchannel)->connected_subchannel)))
-typedef struct {
+namespace {
+struct state_watcher {
grpc_closure closure;
grpc_subchannel* subchannel;
grpc_connectivity_state connectivity_state;
-} state_watcher;
+};
+} // namespace
typedef struct external_state_watcher {
grpc_subchannel* subchannel;
diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc
index a1fb10f5b8..6dbd8c2a6d 100644
--- a/src/core/ext/filters/http/client/http_client_filter.cc
+++ b/src/core/ext/filters/http/client/http_client_filter.cc
@@ -35,7 +35,8 @@
/* default maximum size of payload eligable for GET request */
static const size_t kMaxPayloadSizeForGet = 2048;
-typedef struct call_data {
+namespace {
+struct call_data {
grpc_call_combiner* call_combiner;
// State for handling send_initial_metadata ops.
grpc_linked_mdelem method;
@@ -60,13 +61,14 @@ typedef struct call_data {
grpc_closure on_send_message_next_done;
grpc_closure* original_send_message_on_complete;
grpc_closure send_message_on_complete;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
grpc_mdelem static_scheme;
grpc_mdelem user_agent;
size_t max_payload_size_for_get;
-} channel_data;
+};
+} // namespace
static grpc_error* client_filter_incoming_metadata(grpc_call_element* elem,
grpc_metadata_batch* b) {
diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
index 9ae13d2ed2..92d1716200 100644
--- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc
+++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
@@ -35,16 +35,17 @@
#include "src/core/lib/surface/call.h"
#include "src/core/lib/transport/static_metadata.h"
-typedef enum {
+namespace {
+enum initial_metadata_state {
// Initial metadata not yet seen.
INITIAL_METADATA_UNSEEN = 0,
// Initial metadata seen; compression algorithm set.
HAS_COMPRESSION_ALGORITHM,
// Initial metadata seen; no compression algorithm set.
NO_COMPRESSION_ALGORITHM,
-} initial_metadata_state;
+};
-typedef struct call_data {
+struct call_data {
grpc_call_combiner* call_combiner;
grpc_linked_mdelem compression_algorithm_storage;
grpc_linked_mdelem stream_compression_algorithm_storage;
@@ -62,9 +63,9 @@ typedef struct call_data {
grpc_closure* original_send_message_on_complete;
grpc_closure send_message_on_complete;
grpc_closure on_send_message_next_done;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
/** The default, channel-level, compression algorithm */
grpc_compression_algorithm default_compression_algorithm;
/** Bitset of enabled algorithms */
@@ -78,7 +79,8 @@ typedef struct channel_data {
uint32_t enabled_stream_compression_algorithms_bitset;
/** Supported stream compression algorithms */
uint32_t supported_stream_compression_algorithms;
-} channel_data;
+};
+} // namespace
static bool skip_compression(grpc_call_element* elem, uint32_t flags,
bool has_compression_algorithm) {
diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc
index b872dc98f5..508a3bf9fc 100644
--- a/src/core/ext/filters/http/server/http_server_filter.cc
+++ b/src/core/ext/filters/http/server/http_server_filter.cc
@@ -31,7 +31,8 @@
#define EXPECTED_CONTENT_TYPE "application/grpc"
#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1
-typedef struct call_data {
+namespace {
+struct call_data {
grpc_call_combiner* call_combiner;
grpc_linked_mdelem status;
@@ -60,11 +61,12 @@ typedef struct call_data {
grpc_closure hs_on_recv;
grpc_closure hs_on_complete;
grpc_closure hs_recv_message_ready;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
uint8_t unused;
-} channel_data;
+};
+} // namespace
static grpc_error* server_filter_outgoing_metadata(grpc_call_element* elem,
grpc_metadata_batch* b) {
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
index f50a928fcd..a414229768 100644
--- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
+++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
@@ -31,7 +31,8 @@
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/static_metadata.h"
-typedef struct call_data {
+namespace {
+struct call_data {
intptr_t id; /**< an id unique to the call */
bool have_trailing_md_string;
grpc_slice trailing_md_string;
@@ -48,11 +49,12 @@ typedef struct call_data {
/* to get notified of the availability of the incoming initial metadata. */
grpc_closure on_initial_md_ready;
grpc_metadata_batch* recv_initial_metadata;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
intptr_t id; /**< an id unique to the channel */
-} channel_data;
+};
+} // namespace
static void on_initial_md_ready(void* user_data, grpc_error* err) {
grpc_call_element* elem = (grpc_call_element*)user_data;
diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc
index 0499c6ecfc..7b86e4cd6c 100644
--- a/src/core/ext/filters/max_age/max_age_filter.cc
+++ b/src/core/ext/filters/max_age/max_age_filter.cc
@@ -37,7 +37,8 @@
#define MAX_CONNECTION_IDLE_INTEGER_OPTIONS \
{ DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX }
-typedef struct channel_data {
+namespace {
+struct channel_data {
/* We take a reference to the channel stack for the timer callback */
grpc_channel_stack* channel_stack;
/* Guards access to max_age_timer, max_age_timer_pending, max_age_grace_timer
@@ -84,7 +85,8 @@ typedef struct channel_data {
grpc_connectivity_state connectivity_state;
/* Number of active calls */
gpr_atm call_count;
-} channel_data;
+};
+} // namespace
/* Increase the nubmer of active calls. Before the increasement, if there are no
calls, the max_idle_timer should be cancelled. */
diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc
index f8487f9a9e..3cb7b136c0 100644
--- a/src/core/ext/filters/message_size/message_size_filter.cc
+++ b/src/core/ext/filters/message_size/message_size_filter.cc
@@ -86,7 +86,8 @@ static void* refcounted_message_size_limits_create_from_json(
return value;
}
-typedef struct call_data {
+namespace {
+struct call_data {
grpc_call_combiner* call_combiner;
message_size_limits limits;
// Receive closures are chained: we inject this closure as the
@@ -97,13 +98,14 @@ typedef struct call_data {
grpc_byte_stream** recv_message;
// Original recv_message_ready callback, invoked after our own.
grpc_closure* next_recv_message_ready;
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
message_size_limits limits;
// Maps path names to refcounted_message_size_limits structs.
grpc_slice_hash_table* method_limit_table;
-} channel_data;
+};
+} // namespace
// Callback invoked when we receive a message. Here we check the max
// receive message size.
diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
index 555a9134a2..88bb8c71cc 100644
--- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
+++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
@@ -25,7 +25,8 @@
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/metadata.h"
-typedef struct call_data {
+namespace {
+struct call_data {
// Receive closures are chained: we inject this closure as the
// recv_initial_metadata_ready up-call on transport_stream_op, and remember to
// call our next_recv_initial_metadata_ready member after handling it.
@@ -37,7 +38,8 @@ typedef struct call_data {
// Marks whether the workaround is active
bool workaround_active;
-} call_data;
+};
+} // namespace
// Find the user agent metadata element in the batch
static bool get_user_agent_mdelem(const grpc_metadata_batch* batch,
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc
index 816acf2a23..d47a077251 100644
--- a/src/core/lib/iomgr/tcp_posix.cc
+++ b/src/core/lib/iomgr/tcp_posix.cc
@@ -63,7 +63,8 @@ typedef size_t msg_iovlen_type;
grpc_core::TraceFlag grpc_tcp_trace(false, "tcp");
-typedef struct {
+namespace {
+struct grpc_tcp {
grpc_endpoint base;
grpc_fd* em_fd;
int fd;
@@ -96,12 +97,13 @@ typedef struct {
grpc_resource_user* resource_user;
grpc_resource_user_slice_allocator slice_allocator;
-} grpc_tcp;
+};
-typedef struct backup_poller {
+struct backup_poller {
gpr_mu* pollset_mu;
grpc_closure run_poller;
-} backup_poller;
+};
+} // namespace
#define BACKUP_POLLER_POLLSET(b) ((grpc_pollset*)((b) + 1))
diff --git a/src/core/lib/iomgr/tcp_uv.cc b/src/core/lib/iomgr/tcp_uv.cc
index 2c26b60511..baa49d5cc5 100644
--- a/src/core/lib/iomgr/tcp_uv.cc
+++ b/src/core/lib/iomgr/tcp_uv.cc
@@ -65,6 +65,17 @@ typedef struct {
grpc_pollset* pollset;
} grpc_tcp;
+static grpc_error* tcp_annotate_error(grpc_error* src_error, grpc_tcp* tcp) {
+ return grpc_error_set_str(
+ grpc_error_set_int(
+ src_error,
+ /* All tcp errors are marked with UNAVAILABLE so that application may
+ * choose to retry. */
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
+ GRPC_ERROR_STR_TARGET_ADDRESS,
+ grpc_slice_from_copied_string(tcp->peer_string));
+}
+
static void tcp_free(grpc_tcp* tcp) {
grpc_resource_user_unref(tcp->resource_user);
gpr_free(tcp->handle);
@@ -162,7 +173,8 @@ static void read_callback(uv_stream_t* stream, ssize_t nread,
// TODO(murgatroid99): figure out what the return value here means
uv_read_stop(stream);
if (nread == UV_EOF) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF");
+ error =
+ tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"), tcp);
grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
} else if (nread > 0) {
// Successful read
@@ -177,7 +189,8 @@ static void read_callback(uv_stream_t* stream, ssize_t nread,
}
} else {
// nread < 0: Error
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed");
+ error = tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed"), tcp);
grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
}
call_read_cb(tcp, error);
@@ -194,7 +207,9 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
status =
uv_read_start((uv_stream_t*)tcp->handle, alloc_uv_buf, read_callback);
if (status != 0) {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed at start");
+ error = tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed at start"),
+ tcp);
error = grpc_error_set_str(
error, GRPC_ERROR_STR_OS_ERROR,
grpc_slice_from_static_string(uv_strerror(status)));
@@ -235,7 +250,8 @@ static void write_callback(uv_write_t* req, int status) {
if (status == 0) {
error = GRPC_ERROR_NONE;
} else {
- error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Write failed");
+ error = tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Write failed"), tcp);
}
if (grpc_tcp_trace.enabled()) {
const char* str = grpc_error_string(error);
@@ -268,8 +284,10 @@ static void uv_endpoint_write(grpc_endpoint* ep,
}
if (tcp->shutting_down) {
- GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "TCP socket is shutting down"));
+ GRPC_CLOSURE_SCHED(cb,
+ tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "TCP socket is shutting down"),
+ tcp));
return;
}
diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc
index cd3c2e3f19..6a3641f112 100644
--- a/src/core/lib/security/transport/client_auth_filter.cc
+++ b/src/core/lib/security/transport/client_auth_filter.cc
@@ -37,8 +37,9 @@
#define MAX_CREDENTIALS_METADATA_COUNT 4
+namespace {
/* We can have a per-call credentials. */
-typedef struct {
+struct call_data {
grpc_call_stack* owning_call;
grpc_call_combiner* call_combiner;
grpc_call_credentials* creds;
@@ -57,13 +58,14 @@ typedef struct {
grpc_closure async_result_closure;
grpc_closure check_call_host_cancel_closure;
grpc_closure get_request_metadata_cancel_closure;
-} call_data;
+};
/* We can have a per-channel credentials. */
-typedef struct {
+struct channel_data {
grpc_channel_security_connector* security_connector;
grpc_auth_context* auth_context;
-} channel_data;
+};
+} // namespace
void grpc_auth_metadata_context_reset(
grpc_auth_metadata_context* auth_md_context) {
diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc
index 73653f2a66..f82971dc56 100644
--- a/src/core/lib/security/transport/server_auth_filter.cc
+++ b/src/core/lib/security/transport/server_auth_filter.cc
@@ -26,13 +26,14 @@
#include "src/core/lib/security/transport/auth_filters.h"
#include "src/core/lib/slice/slice_internal.h"
-typedef enum {
+namespace {
+enum async_state {
STATE_INIT = 0,
STATE_DONE,
STATE_CANCELLED,
-} async_state;
+};
-typedef struct call_data {
+struct call_data {
grpc_call_combiner* call_combiner;
grpc_call_stack* owning_call;
grpc_transport_stream_op_batch* recv_initial_metadata_batch;
@@ -44,12 +45,13 @@ typedef struct call_data {
grpc_auth_context* auth_context;
grpc_closure cancel_closure;
gpr_atm state; // async_state
-} call_data;
+};
-typedef struct channel_data {
+struct channel_data {
grpc_auth_context* auth_context;
grpc_server_credentials* creds;
-} channel_data;
+};
+} // namespace
static grpc_metadata_array metadata_batch_to_md_array(
const grpc_metadata_batch* batch) {
diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc
index f1d428f0a1..ee98cf2693 100644
--- a/src/core/lib/surface/server.cc
+++ b/src/core/lib/surface/server.cc
@@ -44,24 +44,23 @@
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
-typedef struct listener {
+grpc_core::TraceFlag grpc_server_channel_trace(false, "server_channel");
+
+namespace {
+struct listener {
void* arg;
void (*start)(grpc_server* server, void* arg, grpc_pollset** pollsets,
size_t pollset_count);
void (*destroy)(grpc_server* server, void* arg, grpc_closure* closure);
struct listener* next;
grpc_closure destroy_done;
-} listener;
+};
-typedef struct call_data call_data;
-typedef struct channel_data channel_data;
-typedef struct registered_method registered_method;
+enum requested_call_type { BATCH_CALL, REGISTERED_CALL };
-typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type;
+struct registered_method;
-grpc_core::TraceFlag grpc_server_channel_trace(false, "server_channel");
-
-typedef struct requested_call {
+struct requested_call {
gpr_mpscq_node request_link; /* must be first */
requested_call_type type;
size_t cq_idx;
@@ -81,15 +80,15 @@ typedef struct requested_call {
grpc_byte_buffer** optional_payload;
} registered;
} data;
-} requested_call;
+};
-typedef struct channel_registered_method {
+struct channel_registered_method {
registered_method* server_registered_method;
uint32_t flags;
bool has_host;
grpc_slice method;
grpc_slice host;
-} channel_registered_method;
+};
struct channel_data {
grpc_server* server;
@@ -176,6 +175,7 @@ typedef struct {
grpc_channel** channels;
size_t num_channels;
} channel_broadcaster;
+} // namespace
struct grpc_server {
grpc_channel_args* channel_args;
diff --git a/tools/bazel.rc b/tools/bazel.rc
index c554f03971..8af2fc981d 100644
--- a/tools/bazel.rc
+++ b/tools/bazel.rc
@@ -1,4 +1,5 @@
build --client_env=CC=clang
+build --copt -DGRPC_BAZEL_BUILD
build:asan --strip=never
build:asan --copt -fsanitize-coverage=edge