From 5d5bd22b0c4d5ef8464068032fda6fc1fe3cfd12 Mon Sep 17 00:00:00 2001 From: Craig Tiller <ctiller@google.com> Date: Mon, 8 Jun 2015 17:01:49 -0700 Subject: [PATCH] Tweaking --- src/core/surface/channel.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 3e5c8a4223..9175ad0572 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -44,6 +44,11 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> +/** Cache grpc-status: X mdelems for X = 0..NUM_CACHED_STATUS_ELEMS. + * Avoids needing to take a metadata context lock for sending status + * if the status code is <= NUM_CACHED_STATUS_ELEMS. + * Sized to allow the most commonly used codes to fit in + * (OK, Cancelled, Unknown). */ #define NUM_CACHED_STATUS_ELEMS 3 typedef struct registered_call { @@ -95,9 +100,8 @@ grpc_channel *grpc_channel_create_from_filters( channel->grpc_status_string = grpc_mdstr_from_string(mdctx, "grpc-status"); channel->grpc_message_string = grpc_mdstr_from_string(mdctx, "grpc-message"); for (i = 0; i < NUM_CACHED_STATUS_ELEMS; i++) { - char buf[2]; - buf[0] = '0' + i; - buf[1] = 0; + char buf[GPR_LTOA_MIN_BUFSIZE]; + gpr_ltoa(i, buf); channel->grpc_status_elem[i] = grpc_mdelem_from_metadata_strings( mdctx, grpc_mdstr_ref(channel->grpc_status_string), grpc_mdstr_from_string(mdctx, buf)); -- GitLab