diff options
author | Craig Tiller <ctiller@google.com> | 2015-06-08 17:01:49 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-06-08 17:01:49 -0700 |
commit | 5d5bd22b0c4d5ef8464068032fda6fc1fe3cfd12 (patch) | |
tree | f4fa3da664fe3b710ecd9605f8434f424da8391b | |
parent | 95cae9b8397109e7a563b753e84e31a57b07d765 (diff) |
Tweaking
-rw-r--r-- | src/core/surface/channel.c | 10 |
1 files 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)); |