From 16c26ed252fa5a186db6e93248325b0f918c8625 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 26 Sep 2016 17:22:03 -0700 Subject: Add support of PUT method --- .../ext/transport/cronet/transport/cronet_transport.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 366690acf2..6c2b53f291 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -531,7 +531,8 @@ static void create_grpc_frame(gpr_slice_buffer *write_slice_buffer, */ static void convert_metadata_to_cronet_headers( grpc_linked_mdelem *head, const char *host, char **pp_url, - cronet_bidirectional_stream_header **pp_headers, size_t *p_num_headers) { + cronet_bidirectional_stream_header **pp_headers, size_t *p_num_headers, + const char ** method) { grpc_linked_mdelem *curr = head; /* Walk the linked list and get number of header fields */ size_t num_headers_available = 0; @@ -558,11 +559,20 @@ static void convert_metadata_to_cronet_headers( curr = curr->next; const char *key = grpc_mdstr_as_c_string(mdelem->key); const char *value = grpc_mdstr_as_c_string(mdelem->value); - if (mdelem->key == GRPC_MDSTR_METHOD || mdelem->key == GRPC_MDSTR_SCHEME || + if (mdelem->key == GRPC_MDSTR_SCHEME || mdelem->key == GRPC_MDSTR_AUTHORITY) { /* Cronet populates these fields on its own */ continue; } + if (mdelem->key == GRPC_MDSTR_METHOD) { + if (mdelem->value == GRPC_MDSTR_PUT) { + *method = grpc_static_metadata_strings[74]; + } else { + /* POST method in default*/ + *method = grpc_static_metadata_strings[71]; + } + continue; + } if (mdelem->key == GRPC_MDSTR_PATH) { /* Create URL by appending :path value to the hostname */ gpr_asprintf(pp_url, "https://%s%s", host, value); @@ -760,14 +770,15 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, &cronet_callbacks); CRONET_LOG(GPR_DEBUG, "%p = cronet_bidirectional_stream_create()", s->cbs); char *url; + const char *method; s->header_array.headers = NULL; convert_metadata_to_cronet_headers( stream_op->send_initial_metadata->list.head, s->curr_ct.host, &url, - &s->header_array.headers, &s->header_array.count); + &s->header_array.headers, &s->header_array.count, &method); s->header_array.capacity = s->header_array.count; CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_start(%p, %s)", s->cbs, url); - cronet_bidirectional_stream_start(s->cbs, url, 0, "POST", &s->header_array, + cronet_bidirectional_stream_start(s->cbs, url, 0, method, &s->header_array, false); stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true; result = ACTION_TAKEN_WITH_CALLBACK; -- cgit v1.2.3 From d7aef05f24472977ee3a976d5321470132ec785c Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 28 Sep 2016 12:05:30 -0700 Subject: Readability improvement --- src/core/ext/transport/cronet/transport/cronet_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 6c2b53f291..6d5fe318cc 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -566,10 +566,10 @@ static void convert_metadata_to_cronet_headers( } if (mdelem->key == GRPC_MDSTR_METHOD) { if (mdelem->value == GRPC_MDSTR_PUT) { - *method = grpc_static_metadata_strings[74]; + *method = (const char*)mdelem->value->slice.data.refcounted.bytes; } else { /* POST method in default*/ - *method = grpc_static_metadata_strings[71]; + *method = (const char*)(GRPC_MDSTR_POST->slice.data.refcounted.bytes); } continue; } -- cgit v1.2.3 From 59c9f904bfe5a9cc7102b44c9440a5e93fdaf159 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 28 Sep 2016 13:33:21 -0700 Subject: Rename GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY to GRPC_INITIAL_METADATA_WAIT_FOR_READY. Also add a flag to indicate whether wait_for_ready was explicitly set by the application. --- include/grpc++/impl/codegen/client_context.h | 6 ++++-- include/grpc/impl/codegen/grpc_types.h | 13 ++++++++++--- src/core/ext/client_config/client_channel.c | 4 ++-- src/cpp/client/client_context.cc | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/core/ext') diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index faabddecc3..dd37e6a850 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -229,10 +229,11 @@ class ClientContext { /// EXPERIMENTAL: Trigger wait-for-ready or not on this request void set_wait_for_ready(bool wait_for_ready) { wait_for_ready_ = wait_for_ready; + wait_for_ready_explicitly_set_ = true; } /// DEPRECATED: Use set_wait_for_ready() instead. - void set_fail_fast(bool fail_fast) { wait_for_ready_ = !fail_fast; } + void set_fail_fast(bool fail_fast) { set_wait_for_ready(!fail_fast); } #ifndef GRPC_CXX0X_NO_CHRONO /// Return the deadline for the client call. @@ -352,7 +353,7 @@ class ClientContext { uint32_t initial_metadata_flags() const { return (idempotent_ ? GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST : 0) | - (wait_for_ready_ ? GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY : 0) | + (wait_for_ready_ ? GRPC_INITIAL_METADATA_WAIT_FOR_READY : 0) | (cacheable_ ? GRPC_INITIAL_METADATA_CACHEABLE_REQUEST : 0); } @@ -360,6 +361,7 @@ class ClientContext { bool initial_metadata_received_; bool wait_for_ready_; + bool wait_for_ready_explicitly_set_; bool idempotent_; bool cacheable_; std::shared_ptr channel_; diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 191cdd0e5f..e9da7e8b71 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -254,15 +254,22 @@ typedef enum grpc_call_error { /** Signal that the call is idempotent */ #define GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST (0x00000010u) /** Signal that the call should not return UNAVAILABLE before it has started */ -#define GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY (0x00000020u) +#define GRPC_INITIAL_METADATA_WAIT_FOR_READY (0x00000020u) +/** DEPRECATED: for backward compatibility */ +#define GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY \ + GRPC_INITIAL_METADATA_WAIT_FOR_READY /** Signal that the call is cacheable. GRPC is free to use GET verb */ #define GRPC_INITIAL_METADATA_CACHEABLE_REQUEST (0x00000040u) +/** Signal that GRPC_INITIAL_METADATA_WAIT_FOR_READY was explicitly set + by the calling application. */ +#define GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET (0x00000080u) /** Mask of all valid flags */ #define GRPC_INITIAL_METADATA_USED_MASK \ (GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST | \ - GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY | \ - GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) + GRPC_INITIAL_METADATA_WAIT_FOR_READY | \ + GRPC_INITIAL_METADATA_CACHEABLE_REQUEST | \ + GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET) /** A single metadata element */ typedef struct grpc_metadata { diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index b2b4fea83c..2c8113c1db 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -110,10 +110,10 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx *exec_ctx, if ((state == GRPC_CHANNEL_TRANSIENT_FAILURE || state == GRPC_CHANNEL_SHUTDOWN) && chand->lb_policy != NULL) { - /* cancel fail-fast picks */ + /* cancel picks with wait_for_ready=false */ grpc_lb_policy_cancel_picks( exec_ctx, chand->lb_policy, - /* mask= */ GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY, + /* mask= */ GRPC_INITIAL_METADATA_WAIT_FOR_READY, /* check= */ 0); } grpc_connectivity_state_set(exec_ctx, &chand->state_tracker, state, error, diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index fb9a7c0459..b6008f47b1 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -60,6 +60,7 @@ static ClientContext::GlobalCallbacks* g_client_callbacks = ClientContext::ClientContext() : initial_metadata_received_(false), wait_for_ready_(false), + wait_for_ready_explicitly_set_(false), idempotent_(false), cacheable_(false), call_(nullptr), -- cgit v1.2.3 From 461fed13cbc581e5593830b228a45e656163b012 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 30 Sep 2016 16:25:35 -0700 Subject: Resolve memory leak in cronet_transport --- .../transport/cronet/transport/cronet_transport.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 366690acf2..1a731f5885 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -341,6 +341,11 @@ static void on_failed(cronet_bidirectional_stream *stream, int net_error) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } + if (s->state.rs.read_buffer && + s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { + gpr_free(s->state.rs.read_buffer); + s->state.rs.read_buffer = NULL; + } gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -363,6 +368,11 @@ static void on_canceled(cronet_bidirectional_stream *stream) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } + if (s->state.rs.read_buffer && + s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { + gpr_free(s->state.rs.read_buffer); + s->state.rs.read_buffer = NULL; + } gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -377,6 +387,11 @@ static void on_succeeded(cronet_bidirectional_stream *stream) { cronet_bidirectional_stream_destroy(s->cbs); s->state.state_callback_received[OP_SUCCEEDED] = true; s->cbs = NULL; + if (s->state.rs.read_buffer && + s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { + gpr_free(s->state.rs.read_buffer); + s->state.rs.read_buffer = NULL; + } gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -901,6 +916,11 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, uint8_t *dst_p = GPR_SLICE_START_PTR(read_data_slice); memcpy(dst_p, stream_state->rs.read_buffer, (size_t)stream_state->rs.length_field); + if (stream_state.rs.read_buffer && + stream_state.rs.read_buffer != stream_state.rs.grpc_header_bytes) { + gpr_free(stream_state.rs.read_buffer); + stream_state.rs.read_buffer = NULL; + } gpr_slice_buffer_init(&stream_state->rs.read_slice_buffer); gpr_slice_buffer_add(&stream_state->rs.read_slice_buffer, read_data_slice); -- cgit v1.2.3 From 0814e3cb179513a1ef96141f51e410416c2fea62 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 30 Sep 2016 16:28:24 -0700 Subject: Minor fixes --- src/core/ext/transport/cronet/transport/cronet_transport.c | 4 ++-- src/objective-c/ProtoRPC/ProtoService.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 6d5fe318cc..6b0ed12b1e 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -566,10 +566,10 @@ static void convert_metadata_to_cronet_headers( } if (mdelem->key == GRPC_MDSTR_METHOD) { if (mdelem->value == GRPC_MDSTR_PUT) { - *method = (const char*)mdelem->value->slice.data.refcounted.bytes; + *method = "PUT"; } else { /* POST method in default*/ - *method = (const char*)(GRPC_MDSTR_POST->slice.data.refcounted.bytes); + *method = "POST"; } continue; } diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h index 5a19fb35db..7faae1b49c 100644 --- a/src/objective-c/ProtoRPC/ProtoService.h +++ b/src/objective-c/ProtoRPC/ProtoService.h @@ -32,7 +32,6 @@ */ #import -#import "ProtoRPC.h" @class GRPCProtoCall; @protocol GRXWriteable; -- cgit v1.2.3 From 20f49619ad4fc1f7ca25e72f4ff5527971186e68 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 30 Sep 2016 16:51:58 -0700 Subject: Simplify the changes using macro --- .../transport/cronet/transport/cronet_transport.c | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 1a731f5885..90f18e413d 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -57,6 +57,14 @@ if (grpc_cronet_trace) gpr_log(__VA_ARGS__); \ } while (0) +#define free_read_buffer(state_rs) \ + if ((state_rs).read_buffer && \ + (state_rs).read_buffer != (state_rs).grpc_header_bytes) { \ + gpr_free((state_rs).read_buffer); \ + (state_rs).read_buffer = NULL; \ + } + + /* TODO (makdharma): Hook up into the wider tracing mechanism */ int grpc_cronet_trace = 0; @@ -341,11 +349,7 @@ static void on_failed(cronet_bidirectional_stream *stream, int net_error) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } - if (s->state.rs.read_buffer && - s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { - gpr_free(s->state.rs.read_buffer); - s->state.rs.read_buffer = NULL; - } + free_read_buffer(s->state.rs); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -368,11 +372,7 @@ static void on_canceled(cronet_bidirectional_stream *stream) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } - if (s->state.rs.read_buffer && - s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { - gpr_free(s->state.rs.read_buffer); - s->state.rs.read_buffer = NULL; - } + free_read_buffer(s->state.rs); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -387,11 +387,7 @@ static void on_succeeded(cronet_bidirectional_stream *stream) { cronet_bidirectional_stream_destroy(s->cbs); s->state.state_callback_received[OP_SUCCEEDED] = true; s->cbs = NULL; - if (s->state.rs.read_buffer && - s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { - gpr_free(s->state.rs.read_buffer); - s->state.rs.read_buffer = NULL; - } + free_read_buffer(s->state.rs); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -916,11 +912,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, uint8_t *dst_p = GPR_SLICE_START_PTR(read_data_slice); memcpy(dst_p, stream_state->rs.read_buffer, (size_t)stream_state->rs.length_field); - if (stream_state.rs.read_buffer && - stream_state.rs.read_buffer != stream_state.rs.grpc_header_bytes) { - gpr_free(stream_state.rs.read_buffer); - stream_state.rs.read_buffer = NULL; - } + free_read_buffer(stream_state->rs); gpr_slice_buffer_init(&stream_state->rs.read_slice_buffer); gpr_slice_buffer_add(&stream_state->rs.read_slice_buffer, read_data_slice); -- cgit v1.2.3 From 92795c405c3961441182f29a9356cf589bb70190 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 3 Oct 2016 09:53:38 -0700 Subject: Update free_read_buffer with a function --- .../transport/cronet/transport/cronet_transport.c | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 90f18e413d..b95aba14e9 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -57,14 +57,6 @@ if (grpc_cronet_trace) gpr_log(__VA_ARGS__); \ } while (0) -#define free_read_buffer(state_rs) \ - if ((state_rs).read_buffer && \ - (state_rs).read_buffer != (state_rs).grpc_header_bytes) { \ - gpr_free((state_rs).read_buffer); \ - (state_rs).read_buffer = NULL; \ - } - - /* TODO (makdharma): Hook up into the wider tracing mechanism */ int grpc_cronet_trace = 0; @@ -247,6 +239,14 @@ static const char *op_id_string(enum e_op_id i) { return "UNKNOWN"; } +static void free_read_buffer(stream_obj *s) { + if (s->state.rs.read_buffer && + s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { + gpr_free(s->state.rs.read_buffer); + s->state.rs.read_buffer = NULL; + } +} + /* Add a new stream op to op storage. */ @@ -349,7 +349,7 @@ static void on_failed(cronet_bidirectional_stream *stream, int net_error) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } - free_read_buffer(s->state.rs); + free_read_buffer(s); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -372,7 +372,7 @@ static void on_canceled(cronet_bidirectional_stream *stream) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } - free_read_buffer(s->state.rs); + free_read_buffer(s); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -387,7 +387,7 @@ static void on_succeeded(cronet_bidirectional_stream *stream) { cronet_bidirectional_stream_destroy(s->cbs); s->state.state_callback_received[OP_SUCCEEDED] = true; s->cbs = NULL; - free_read_buffer(s->state.rs); + free_read_buffer(s); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -912,7 +912,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, uint8_t *dst_p = GPR_SLICE_START_PTR(read_data_slice); memcpy(dst_p, stream_state->rs.read_buffer, (size_t)stream_state->rs.length_field); - free_read_buffer(stream_state->rs); + free_read_buffer(s); gpr_slice_buffer_init(&stream_state->rs.read_slice_buffer); gpr_slice_buffer_add(&stream_state->rs.read_slice_buffer, read_data_slice); -- cgit v1.2.3 From c7cf9a69a4299fffd071c0436df43a0a187a60fa Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Wed, 5 Oct 2016 17:36:14 -0700 Subject: Fix maybe-uninitialized variable --- src/core/ext/transport/cronet/transport/cronet_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 19e43673b9..984a8bb555 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -781,7 +781,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, &cronet_callbacks); CRONET_LOG(GPR_DEBUG, "%p = cronet_bidirectional_stream_create()", s->cbs); char *url; - const char *method; + const char *method = NULL; s->header_array.headers = NULL; convert_metadata_to_cronet_headers( stream_op->send_initial_metadata->list.head, s->curr_ct.host, &url, -- cgit v1.2.3 From 4552f6aad888878fb15b292c134b5d90233d5491 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Wed, 5 Oct 2016 17:54:00 -0700 Subject: Init method as POST --- src/core/ext/transport/cronet/transport/cronet_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 984a8bb555..4431d58351 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -781,7 +781,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, &cronet_callbacks); CRONET_LOG(GPR_DEBUG, "%p = cronet_bidirectional_stream_create()", s->cbs); char *url; - const char *method = NULL; + const char *method = "POST"; s->header_array.headers = NULL; convert_metadata_to_cronet_headers( stream_op->send_initial_metadata->list.head, s->curr_ct.host, &url, -- cgit v1.2.3 From bc4ea6d727692c1720df7a3480f8d86c73d68df0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 6 Oct 2016 14:01:02 +0200 Subject: fix compilation error --- src/core/ext/transport/cronet/transport/cronet_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 19e43673b9..f7f57ac825 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -780,8 +780,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, s->cbs = cronet_bidirectional_stream_create(s->curr_ct.engine, s->curr_gs, &cronet_callbacks); CRONET_LOG(GPR_DEBUG, "%p = cronet_bidirectional_stream_create()", s->cbs); - char *url; - const char *method; + char *url = NULL; + const char *method = NULL; s->header_array.headers = NULL; convert_metadata_to_cronet_headers( stream_op->send_initial_metadata->list.head, s->curr_ct.host, &url, -- cgit v1.2.3 From 1e5f6af0c7deda7a101d9842fba78682f5c7aa0c Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 7 Oct 2016 08:32:58 -0700 Subject: Fix grpclb LB policy pick method to return 0 upon error. --- src/core/ext/client_config/lb_policy.h | 21 ++++++++++++--------- src/core/ext/lb_policy/grpclb/grpclb.c | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/core/ext') diff --git a/src/core/ext/client_config/lb_policy.h b/src/core/ext/client_config/lb_policy.h index 6cc3e1ebd3..110d08fcac 100644 --- a/src/core/ext/client_config/lb_policy.h +++ b/src/core/ext/client_config/lb_policy.h @@ -142,15 +142,18 @@ void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy); void grpc_lb_policy_init(grpc_lb_policy *policy, const grpc_lb_policy_vtable *vtable); -/** Find an appropriate target for this call, based on \a pick_args. - Picking can be synchronous or asynchronous. In the synchronous case, when a - pick is readily available, it'll be returned in \a target and a non-zero - value will be returned. - In the asynchronous case, zero is returned and \a on_complete will be called - once \a target and \a user_data have been set. Any IO should be done under - \a pick_args->pollent. The opaque \a user_data output argument corresponds - to information that may need be propagated from the LB policy. It may be - NULL. Errors are signaled by receiving a NULL \a *target. */ +/** Finds an appropriate subchannel for a call, based on \a pick_args. + + \a target will be set to the selected subchannel, or NULL on failure. + Upon success, \a user_data will be set to whatever opaque information + may need to be propagated from the LB policy, or NULL if not needed. + + If the pick succeeds and a result is known immediately, a non-zero + value will be returned. Otherwise, \a on_complete will be invoked + once the pick is complete with its error argument set to indicate + success or failure. + + Any I/O should be done under \a pick_args->pollent. */ int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy, const grpc_lb_policy_pick_args *pick_args, grpc_connected_subchannel **target, void **user_data, diff --git a/src/core/ext/lb_policy/grpclb/grpclb.c b/src/core/ext/lb_policy/grpclb/grpclb.c index 63af774ea6..ae1f2a3b4c 100644 --- a/src/core/ext/lb_policy/grpclb/grpclb.c +++ b/src/core/ext/lb_policy/grpclb/grpclb.c @@ -761,7 +761,7 @@ static int glb_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, GRPC_ERROR_CREATE("No mdelem storage for the LB token. Load reporting " "won't work without it. Failing"), NULL); - return 1; + return 0; } glb_lb_policy *glb_policy = (glb_lb_policy *)pol; -- cgit v1.2.3 From cf16b76b9a85c801c51aab3b3fe7a1735a6839a4 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 7 Oct 2016 09:51:03 -0700 Subject: clang-format --- src/core/ext/transport/cronet/transport/cronet_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/ext') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 00a5be419e..25ad40b935 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -543,7 +543,7 @@ static void create_grpc_frame(gpr_slice_buffer *write_slice_buffer, static void convert_metadata_to_cronet_headers( grpc_linked_mdelem *head, const char *host, char **pp_url, cronet_bidirectional_stream_header **pp_headers, size_t *p_num_headers, - const char ** method) { + const char **method) { grpc_linked_mdelem *curr = head; /* Walk the linked list and get number of header fields */ size_t num_headers_available = 0; -- cgit v1.2.3