From 6046dc35efe8263f59e405ae679059a6c65111f7 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 14 Jan 2015 12:55:45 -0800 Subject: [PATCH] clang-format --- include/grpc/grpc.h | 8 +++++--- src/core/support/log_posix.c | 1 - src/core/surface/call.c | 17 +++++++++++------ src/cpp/stream/stream_context.cc | 15 +++++++-------- test/core/util/test_config.c | 8 ++------ 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index f9d8cce8475..45915cbfadf 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -366,12 +366,14 @@ grpc_call_error grpc_call_server_end_initial_metadata(grpc_call *call, grpc_call_error grpc_call_cancel(grpc_call *call); /* Called by clients to cancel an RPC on the server. - Can be called multiple times, from any thread. + Can be called multiple times, from any thread. If a status has not been received for the call, set it to the status code - and description passed in. + and description passed in. Importantly, this function does not send status nor description to the remote endpoint. */ -grpc_call_error grpc_call_cancel_with_status(grpc_call *call, grpc_status_code status, const char *description); +grpc_call_error grpc_call_cancel_with_status(grpc_call *call, + grpc_status_code status, + const char *description); /* Queue a byte buffer for writing. flags is a bit-field combination of the write flags defined above. diff --git a/src/core/support/log_posix.c b/src/core/support/log_posix.c index 55a38b136d0..ee2705a2c20 100644 --- a/src/core/support/log_posix.c +++ b/src/core/support/log_posix.c @@ -31,7 +31,6 @@ * */ - #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L #endif diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 4ce958171b5..3579a5bb9fa 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -278,9 +278,9 @@ static void maybe_set_status_code(grpc_call *call, gpr_uint32 status) { } static void maybe_set_status_details(grpc_call *call, grpc_mdstr *status) { - if (!call->status_details) { - call->status_details = grpc_mdstr_ref(status); - } + if (!call->status_details) { + call->status_details = grpc_mdstr_ref(status); + } } grpc_call_error grpc_call_cancel(grpc_call *c) { @@ -299,8 +299,12 @@ grpc_call_error grpc_call_cancel(grpc_call *c) { return GRPC_CALL_OK; } -grpc_call_error grpc_call_cancel_with_status(grpc_call *c, grpc_status_code status, const char *description) { - grpc_mdstr *details = description? grpc_mdstr_from_string(c->metadata_context, description) : NULL; +grpc_call_error grpc_call_cancel_with_status(grpc_call *c, + grpc_status_code status, + const char *description) { + grpc_mdstr *details = + description ? grpc_mdstr_from_string(c->metadata_context, description) + : NULL; gpr_mu_lock(&c->read_mu); maybe_set_status_code(c, status); if (details) { @@ -825,7 +829,8 @@ void grpc_call_recv_metadata(grpc_call_element *elem, grpc_call_op *op) { grpc_call *call = CALL_FROM_TOP_ELEM(elem); grpc_mdelem *md = op->data.metadata; grpc_mdstr *key = md->key; - gpr_log(GPR_DEBUG, "call %p got metadata %s %s", call, grpc_mdstr_as_c_string(md->key), grpc_mdstr_as_c_string(md->value)); + gpr_log(GPR_DEBUG, "call %p got metadata %s %s", call, + grpc_mdstr_as_c_string(md->key), grpc_mdstr_as_c_string(md->value)); if (key == grpc_channel_get_status_string(call->channel)) { maybe_set_status_code(call, decode_status(md)); grpc_mdelem_unref(md); diff --git a/src/cpp/stream/stream_context.cc b/src/cpp/stream/stream_context.cc index d46ba6e56ae..5ccf8c96828 100644 --- a/src/cpp/stream/stream_context.cc +++ b/src/cpp/stream/stream_context.cc @@ -112,7 +112,8 @@ bool StreamContext::Read(google::protobuf::Message* msg) { if (read_ev->data.read) { if (!DeserializeProto(read_ev->data.read, msg)) { ret = false; - grpc_call_cancel_with_status(call(), GRPC_STATUS_DATA_LOSS, "Failed to parse incoming proto"); + grpc_call_cancel_with_status(call(), GRPC_STATUS_DATA_LOSS, + "Failed to parse incoming proto"); } } else { ret = false; @@ -130,7 +131,8 @@ bool StreamContext::Write(const google::protobuf::Message* msg, bool is_last) { if (msg) { grpc_byte_buffer* out_buf = nullptr; if (!SerializeProto(*msg, &out_buf)) { - grpc_call_cancel_with_status(call(), GRPC_STATUS_INVALID_ARGUMENT, "Failed to serialize outgoing proto"); + grpc_call_cancel_with_status(call(), GRPC_STATUS_INVALID_ARGUMENT, + "Failed to serialize outgoing proto"); return false; } int flag = is_last ? GRPC_WRITE_BUFFER_HINT : 0; @@ -169,20 +171,17 @@ const Status& StreamContext::Wait() { // TODO(yangg) protect states by a mutex, including other places. if (!self_halfclosed_ || !peer_halfclosed_) { Cancel(); - } + } grpc_event* finish_ev = grpc_completion_queue_pluck(cq(), finished_tag(), gpr_inf_future); GPR_ASSERT(finish_ev->type == GRPC_FINISHED); final_status_ = Status( static_cast(finish_ev->data.finished.status), - finish_ev->data.finished.details ? finish_ev->data.finished.details - : ""); + finish_ev->data.finished.details ? finish_ev->data.finished.details : ""); grpc_event_finish(finish_ev); return final_status_; } -void StreamContext::Cancel() { - grpc_call_cancel(call()); -} +void StreamContext::Cancel() { grpc_call_cancel(call()); } } // namespace grpc diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index ab2c0d80a99..a9a687835e7 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -38,16 +38,12 @@ #if GPR_GETPID_IN_UNISTD_H #include -static int seed() { - return getpid(); -} +static int seed() { return getpid(); } #endif #if GPR_GETPID_IN_PROCESS_H #include -static int seed(void) { - return _getpid(); -} +static int seed(void) { return _getpid(); } #endif void grpc_test_init(int argc, char **argv) {