Various fixes and clean-ups.

pull/8303/head
Mark D. Roth 8 years ago
parent 408913845c
commit d51e0352c5
  1. 4
      src/core/ext/client_config/client_channel.c
  2. 19
      src/core/ext/client_config/method_config.c
  3. 2
      src/core/ext/client_config/method_config.h
  4. 5
      src/core/ext/client_config/resolver_result.c
  5. 2
      src/core/ext/client_config/resolver_result.h
  6. 4
      src/core/lib/channel/channel_args.c
  7. 4
      src/core/lib/channel/channel_args.h
  8. 2
      src/core/lib/transport/hashtable.c

@ -811,7 +811,9 @@ static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx,
*wait_for_ready ? WAIT_FOR_READY_TRUE : WAIT_FOR_READY_FALSE;
}
}
grpc_method_config_table_unref(chand->method_config_table);
if (method_config_table != NULL) {
grpc_method_config_table_unref(method_config_table);
}
calld->deadline = args->deadline;
calld->path = GRPC_MDSTR_REF(args->path);
calld->cancel_error = GRPC_ERROR_NONE;

@ -121,35 +121,35 @@ grpc_method_config* grpc_method_config_create(
int32_t* max_request_message_bytes, int32_t* max_response_message_bytes) {
grpc_method_config* method_config = gpr_malloc(sizeof(grpc_method_config));
memset(method_config, 0, sizeof(grpc_method_config));
method_config->wait_for_ready_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_WAIT_FOR_READY);
method_config->timeout_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_TIMEOUT);
method_config->max_request_message_bytes_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_MAX_REQUEST_MESSAGE_BYTES);
method_config->max_response_message_bytes_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_MAX_RESPONSE_MESSAGE_BYTES);
grpc_hash_table_entry entries[4];
size_t num_entries = 0;
if (wait_for_ready != NULL) {
method_config->wait_for_ready_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_WAIT_FOR_READY);
entries[num_entries].key = method_config->wait_for_ready_key;
entries[num_entries].value = wait_for_ready;
entries[num_entries].vtable = &bool_vtable;
++num_entries;
}
if (timeout != NULL) {
method_config->timeout_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_TIMEOUT);
entries[num_entries].key = method_config->timeout_key;
entries[num_entries].value = timeout;
entries[num_entries].vtable = &timespec_vtable;
++num_entries;
}
if (max_request_message_bytes != NULL) {
method_config->max_request_message_bytes_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_MAX_REQUEST_MESSAGE_BYTES);
entries[num_entries].key = method_config->max_request_message_bytes_key;
entries[num_entries].value = max_request_message_bytes;
entries[num_entries].vtable = &int32_vtable;
++num_entries;
}
if (max_response_message_bytes != NULL) {
method_config->max_response_message_bytes_key =
grpc_mdstr_from_string(GRPC_METHOD_CONFIG_MAX_RESPONSE_MESSAGE_BYTES);
entries[num_entries].key = method_config->max_response_message_bytes_key;
entries[num_entries].value = max_response_message_bytes;
entries[num_entries].vtable = &int32_vtable;
@ -170,6 +170,7 @@ void grpc_method_config_unref(grpc_method_config* method_config) {
GRPC_MDSTR_UNREF(method_config->timeout_key);
GRPC_MDSTR_UNREF(method_config->max_request_message_bytes_key);
GRPC_MDSTR_UNREF(method_config->max_response_message_bytes_key);
gpr_free(method_config);
}
}
@ -261,7 +262,7 @@ grpc_method_config* grpc_method_config_table_get_method_config(
method_config = grpc_hash_table_get(table, wildcard_path);
GRPC_MDSTR_UNREF(wildcard_path);
}
return grpc_method_config_ref(method_config);
return method_config;
}
static void* copy_arg(void* p) {

@ -86,7 +86,7 @@ int grpc_method_config_table_cmp(grpc_method_config_table* table1,
grpc_method_config_table* table2);
/// Returns NULL if the method has no config.
/// Caller owns a reference to result.
/// Caller does NOT own a reference to the result.
grpc_method_config* grpc_method_config_table_get_method_config(
grpc_method_config_table* table, grpc_mdstr* path);

@ -36,13 +36,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/channel/channel_args.h"
//
// grpc_resolver_result
//
struct grpc_resolver_result {
gpr_refcount refs;
char* server_name;

@ -48,7 +48,7 @@
/// Results reported from a grpc_resolver.
typedef struct grpc_resolver_result grpc_resolver_result;
/// Takes ownership of \a addresses, \a lb_policy_args.
/// Takes ownership of \a addresses and \a lb_policy_args.
grpc_resolver_result* grpc_resolver_result_create(
const char* server_name, grpc_lb_addresses* addresses,
const char* lb_policy_name, grpc_channel_args* lb_policy_args);

@ -276,7 +276,9 @@ const grpc_arg *grpc_channel_args_find(const grpc_channel_args *args,
const char *name) {
if (args != NULL) {
for (size_t i = 0; i < args->num_args; ++i) {
if (args->args[i].key == name) return &args->args[i];
if (strcmp(args->args[i].key, name) == 0) {
return &args->args[i];
}
}
}
return NULL;

@ -89,9 +89,7 @@ uint32_t grpc_channel_args_compression_algorithm_get_states(
int grpc_channel_args_compare(const grpc_channel_args *a,
const grpc_channel_args *b);
/** Returns the value of argument \a name from \a args, or NULL if not found.
Note: \a name is matched using pointer equality, so it must be the
same instance of the string used to create the grpc_arg key. */
/** Returns the value of argument \a name from \a args, or NULL if not found. */
const grpc_arg *grpc_channel_args_find(const grpc_channel_args *args,
const char *name);

@ -77,7 +77,7 @@ grpc_hash_table* grpc_hash_table_create(size_t num_entries,
grpc_hash_table* table = gpr_malloc(sizeof(*table));
memset(table, 0, sizeof(*table));
gpr_ref_init(&table->refs, 1);
// Quadratic chaining gets best performance when the table is no more
// Quadratic probing gets best performance when the table is no more
// than half full.
table->num_entries = num_entries * 2;
const size_t entry_size = sizeof(grpc_hash_table_entry) * table->num_entries;

Loading…
Cancel
Save