Backports of 18445 and 18517.

pull/18633/head
Nicolas "Pixel" Noble 6 years ago
parent a6690f7543
commit f97b47c87c
  1. 4
      src/core/ext/filters/client_channel/health/health_check_client.cc
  2. 1
      src/core/lib/security/credentials/google_default/google_default_credentials.cc
  3. 16
      src/core/lib/transport/transport.cc
  4. 26
      src/core/lib/transport/transport.h

@ -349,7 +349,6 @@ void HealthCheckClient::CallState::StartCall() {
return; return;
} }
// Initialize payload and batch. // Initialize payload and batch.
memset(&batch_, 0, sizeof(batch_));
payload_.context = context_; payload_.context = context_;
batch_.payload = &payload_; batch_.payload = &payload_;
// on_complete callback takes ref, handled manually. // on_complete callback takes ref, handled manually.
@ -401,8 +400,6 @@ void HealthCheckClient::CallState::StartCall() {
// Start batch. // Start batch.
StartBatch(&batch_); StartBatch(&batch_);
// Initialize recv_trailing_metadata batch. // Initialize recv_trailing_metadata batch.
memset(&recv_trailing_metadata_batch_, 0,
sizeof(recv_trailing_metadata_batch_));
recv_trailing_metadata_batch_.payload = &payload_; recv_trailing_metadata_batch_.payload = &payload_;
// Add recv_trailing_metadata op. // Add recv_trailing_metadata op.
grpc_metadata_batch_init(&recv_trailing_metadata_); grpc_metadata_batch_init(&recv_trailing_metadata_);
@ -507,7 +504,6 @@ void HealthCheckClient::CallState::DoneReadingRecvMessage(grpc_error* error) {
// This re-uses the ref we're holding. // This re-uses the ref we're holding.
// Note: Can't just reuse batch_ here, since we don't know that all // Note: Can't just reuse batch_ here, since we don't know that all
// callbacks from the original batch have completed yet. // callbacks from the original batch have completed yet.
memset(&recv_message_batch_, 0, sizeof(recv_message_batch_));
recv_message_batch_.payload = &payload_; recv_message_batch_.payload = &payload_;
payload_.recv_message.recv_message = &recv_message_; payload_.recv_message.recv_message = &recv_message_;
payload_.recv_message.recv_message_ready = GRPC_CLOSURE_INIT( payload_.recv_message.recv_message_ready = GRPC_CLOSURE_INIT(

@ -172,7 +172,6 @@ static int is_metadata_server_reachable() {
detector.pollent = grpc_polling_entity_create_from_pollset(pollset); detector.pollent = grpc_polling_entity_create_from_pollset(pollset);
detector.is_done = 0; detector.is_done = 0;
detector.success = 0; detector.success = 0;
memset(&detector.response, 0, sizeof(detector.response));
memset(&request, 0, sizeof(grpc_httpcli_request)); memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = (char*)GRPC_COMPUTE_ENGINE_DETECTION_HOST; request.host = (char*)GRPC_COMPUTE_ENGINE_DETECTION_HOST;
request.http.path = (char*)"/"; request.http.path = (char*)"/";

@ -29,6 +29,7 @@
#include "src/core/lib/gpr/alloc.h" #include "src/core/lib/gpr/alloc.h"
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_internal.h"
@ -243,25 +244,26 @@ void grpc_transport_stream_op_batch_finish_with_failure(
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }
typedef struct { struct made_transport_op {
grpc_closure outer_on_complete; grpc_closure outer_on_complete;
grpc_closure* inner_on_complete; grpc_closure* inner_on_complete = nullptr;
grpc_transport_op op; grpc_transport_op op;
} made_transport_op; made_transport_op() {
memset(&outer_on_complete, 0, sizeof(outer_on_complete));
}
};
static void destroy_made_transport_op(void* arg, grpc_error* error) { static void destroy_made_transport_op(void* arg, grpc_error* error) {
made_transport_op* op = static_cast<made_transport_op*>(arg); made_transport_op* op = static_cast<made_transport_op*>(arg);
GRPC_CLOSURE_SCHED(op->inner_on_complete, GRPC_ERROR_REF(error)); GRPC_CLOSURE_SCHED(op->inner_on_complete, GRPC_ERROR_REF(error));
gpr_free(op); grpc_core::Delete<made_transport_op>(op);
} }
grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) { grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) {
made_transport_op* op = made_transport_op* op = grpc_core::New<made_transport_op>();
static_cast<made_transport_op*>(gpr_malloc(sizeof(*op)));
GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op, GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
op->inner_on_complete = on_complete; op->inner_on_complete = on_complete;
memset(&op->op, 0, sizeof(op->op));
op->op.on_consumed = &op->outer_on_complete; op->op.on_consumed = &op->outer_on_complete;
return &op->op; return &op->op;
} }

@ -273,40 +273,40 @@ struct grpc_transport_stream_op_batch_payload {
/** Transport op: a set of operations to perform on a transport as a whole */ /** Transport op: a set of operations to perform on a transport as a whole */
typedef struct grpc_transport_op { typedef struct grpc_transport_op {
/** Called when processing of this op is done. */ /** Called when processing of this op is done. */
grpc_closure* on_consumed; grpc_closure* on_consumed = nullptr;
/** connectivity monitoring - set connectivity_state to NULL to unsubscribe */ /** connectivity monitoring - set connectivity_state to NULL to unsubscribe */
grpc_closure* on_connectivity_state_change; grpc_closure* on_connectivity_state_change = nullptr;
grpc_connectivity_state* connectivity_state; grpc_connectivity_state* connectivity_state = nullptr;
/** should the transport be disconnected /** should the transport be disconnected
* Error contract: the transport that gets this op must cause * Error contract: the transport that gets this op must cause
* disconnect_with_error to be unref'ed after processing it */ * disconnect_with_error to be unref'ed after processing it */
grpc_error* disconnect_with_error; grpc_error* disconnect_with_error = nullptr;
/** what should the goaway contain? /** what should the goaway contain?
* Error contract: the transport that gets this op must cause * Error contract: the transport that gets this op must cause
* goaway_error to be unref'ed after processing it */ * goaway_error to be unref'ed after processing it */
grpc_error* goaway_error; grpc_error* goaway_error = nullptr;
/** set the callback for accepting new streams; /** set the callback for accepting new streams;
this is a permanent callback, unlike the other one-shot closures. this is a permanent callback, unlike the other one-shot closures.
If true, the callback is set to set_accept_stream_fn, with its If true, the callback is set to set_accept_stream_fn, with its
user_data argument set to set_accept_stream_user_data */ user_data argument set to set_accept_stream_user_data */
bool set_accept_stream; bool set_accept_stream = false;
void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport, void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport,
const void* server_data); const void* server_data) = nullptr;
void* set_accept_stream_user_data; void* set_accept_stream_user_data = nullptr;
/** add this transport to a pollset */ /** add this transport to a pollset */
grpc_pollset* bind_pollset; grpc_pollset* bind_pollset = nullptr;
/** add this transport to a pollset_set */ /** add this transport to a pollset_set */
grpc_pollset_set* bind_pollset_set; grpc_pollset_set* bind_pollset_set = nullptr;
/** send a ping, if either on_initiate or on_ack is not NULL */ /** send a ping, if either on_initiate or on_ack is not NULL */
struct { struct {
/** Ping may be delayed by the transport, on_initiate callback will be /** Ping may be delayed by the transport, on_initiate callback will be
called when the ping is actually being sent. */ called when the ping is actually being sent. */
grpc_closure* on_initiate; grpc_closure* on_initiate = nullptr;
/** Called when the ping ack is received */ /** Called when the ping ack is received */
grpc_closure* on_ack; grpc_closure* on_ack = nullptr;
} send_ping; } send_ping;
// If true, will reset the channel's connection backoff. // If true, will reset the channel's connection backoff.
bool reset_connect_backoff; bool reset_connect_backoff = false;
/*************************************************************************** /***************************************************************************
* remaining fields are initialized and used at the discretion of the * remaining fields are initialized and used at the discretion of the

Loading…
Cancel
Save