clang-format

pull/34/head
Craig Tiller 10 years ago
parent 465e2e11d1
commit 09b637538f
  1. 4
      include/grpc/grpc.h
  2. 17
      src/core/surface/call.c
  3. 5
      src/cpp/client/channel.cc
  4. 18
      src/cpp/stream/stream_context.cc
  5. 4
      test/core/end2end/tests/thread_stress.c

@ -375,7 +375,9 @@ grpc_call_error grpc_call_cancel(grpc_call *call);
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.

@ -286,9 +286,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) {
@ -307,8 +307,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) {
@ -898,7 +902,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);

@ -114,9 +114,8 @@ Status Channel::StartBlockingRpc(const RpcMethod& method,
// add_metadata from context
//
// invoke
GPR_ASSERT(grpc_call_invoke(call, cq, metadata_read_tag,
finished_tag,
GRPC_WRITE_BUFFER_HINT) == GRPC_CALL_OK);
GPR_ASSERT(grpc_call_invoke(call, cq, metadata_read_tag, finished_tag,
GRPC_WRITE_BUFFER_HINT) == GRPC_CALL_OK);
// write request
grpc_byte_buffer* write_buffer = nullptr;
bool success = SerializeProto(request, &write_buffer);

@ -80,9 +80,8 @@ void StreamContext::Start(bool buffered) {
if (is_client_) {
// TODO(yangg) handle metadata send path
int flag = buffered ? GRPC_WRITE_BUFFER_HINT : 0;
grpc_call_error error = grpc_call_invoke(call(), cq(),
client_metadata_read_tag(),
finished_tag(), flag);
grpc_call_error error = grpc_call_invoke(
call(), cq(), client_metadata_read_tag(), finished_tag(), flag);
GPR_ASSERT(GRPC_CALL_OK == error);
} else {
// TODO(yangg) metadata needs to be added before accept
@ -105,7 +104,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;
@ -123,7 +123,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;
@ -168,14 +169,11 @@ const Status& StreamContext::Wait() {
GPR_ASSERT(finish_ev->type == GRPC_FINISHED);
final_status_ = Status(
static_cast<StatusCode>(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

@ -116,8 +116,8 @@ static void start_request() {
gpr_slice_unref(slice);
g_active_requests++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_invoke(call, g_fixture.client_cq,
NULL, NULL, 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_invoke(call, g_fixture.client_cq, NULL, NULL, 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_read(call, NULL));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write(call, buf, NULL, 0));

Loading…
Cancel
Save