clang-format

pull/1464/head
Yang Gao 10 years ago
parent f7d05b572b
commit c71a9d2b56
  1. 5
      src/core/profiling/basic_timers.c
  2. 6
      src/core/profiling/stap_timers.c
  3. 15
      src/core/profiling/timers.h
  4. 4
      src/core/support/cpu_windows.c
  5. 19
      src/core/surface/call.c
  6. 7
      src/cpp/common/call.cc
  7. 9
      src/cpp/server/server.cc
  8. 4
      test/build/systemtap.c
  9. 9
      test/cpp/end2end/end2end_test.cc

@ -135,8 +135,8 @@ void grpc_timer_add_mark(int tag, void* id, const char* file, int line) {
grpc_timers_log_add(grpc_timers_log_global, tag, id, file, line); grpc_timers_log_add(grpc_timers_log_global, tag, id, file, line);
} }
void grpc_timer_begin(int tag, void* id, const char *file, int line) {} void grpc_timer_begin(int tag, void* id, const char* file, int line) {}
void grpc_timer_end(int tag, void* id, const char *file, int line) {} void grpc_timer_end(int tag, void* id, const char* file, int line) {}
/* Basic profiler specific API functions. */ /* Basic profiler specific API functions. */
void grpc_timers_global_init(void) { void grpc_timers_global_init(void) {
@ -147,7 +147,6 @@ void grpc_timers_global_destroy(void) {
grpc_timers_log_destroy(grpc_timers_log_global); grpc_timers_log_destroy(grpc_timers_log_global);
} }
#else /* !GRPC_BASIC_PROFILER */ #else /* !GRPC_BASIC_PROFILER */
void grpc_timers_global_init(void) {} void grpc_timers_global_init(void) {}
void grpc_timers_global_destroy(void) {} void grpc_timers_global_destroy(void) {}

@ -42,15 +42,15 @@
#include "src/core/profiling/stap_probes.h" #include "src/core/profiling/stap_probes.h"
/* Latency profiler API implementation. */ /* Latency profiler API implementation. */
void grpc_timer_add_mark(int tag, void* id, const char *file, int line) { void grpc_timer_add_mark(int tag, void* id, const char* file, int line) {
_STAP_ADD_MARK(tag); _STAP_ADD_MARK(tag);
} }
void grpc_timer_begin(int tag, void* id, const char *file, int line) { void grpc_timer_begin(int tag, void* id, const char* file, int line) {
_STAP_TIMING_NS_BEGIN(tag); _STAP_TIMING_NS_BEGIN(tag);
} }
void grpc_timer_end(int tag, void* id, const char *file, int line) { void grpc_timer_end(int tag, void* id, const char* file, int line) {
_STAP_TIMING_NS_END(tag); _STAP_TIMING_NS_END(tag);
} }

@ -41,9 +41,9 @@ extern "C" {
void grpc_timers_global_init(void); void grpc_timers_global_init(void);
void grpc_timers_global_destroy(void); void grpc_timers_global_destroy(void);
void grpc_timer_add_mark(int tag, void* id, const char *file, int line); void grpc_timer_add_mark(int tag, void *id, const char *file, int line);
void grpc_timer_begin(int tag, void* id, const char *file, int line); void grpc_timer_begin(int tag, void *id, const char *file, int line);
void grpc_timer_end(int tag, void* id, const char *file, int line); void grpc_timer_end(int tag, void *id, const char *file, int line);
enum grpc_profiling_tags { enum grpc_profiling_tags {
/* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */ /* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */
@ -74,13 +74,16 @@ enum grpc_profiling_tags {
#if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER)) #if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER))
/* No profiling. No-op all the things. */ /* No profiling. No-op all the things. */
#define GRPC_TIMER_MARK(tag, id) \ #define GRPC_TIMER_MARK(tag, id) \
do {} while(0) do { \
} while (0)
#define GRPC_TIMER_BEGIN(tag, id) \ #define GRPC_TIMER_BEGIN(tag, id) \
do {} while(0) do { \
} while (0)
#define GRPC_TIMER_END(tag, id) \ #define GRPC_TIMER_END(tag, id) \
do {} while(0) do { \
} while (0)
#else /* at least one profiler requested... */ #else /* at least one profiler requested... */
/* ... hopefully only one. */ /* ... hopefully only one. */

@ -43,8 +43,6 @@ unsigned gpr_cpu_num_cores(void) {
return si.dwNumberOfProcessors; return si.dwNumberOfProcessors;
} }
unsigned gpr_cpu_current_cpu(void) { unsigned gpr_cpu_current_cpu(void) { return GetCurrentProcessorNumber(); }
return GetCurrentProcessorNumber();
}
#endif /* GPR_WIN32 */ #endif /* GPR_WIN32 */

@ -246,9 +246,8 @@ static int fill_send_ops(grpc_call *call, grpc_transport_op *op);
static void execute_op(grpc_call *call, grpc_transport_op *op); static void execute_op(grpc_call *call, grpc_transport_op *op);
static void recv_metadata(grpc_call *call, grpc_metadata_batch *metadata); static void recv_metadata(grpc_call *call, grpc_metadata_batch *metadata);
static void finish_read_ops(grpc_call *call); static void finish_read_ops(grpc_call *call);
static grpc_call_error grpc_call_cancel_with_status_internal(grpc_call *c, static grpc_call_error grpc_call_cancel_with_status_internal(
grpc_status_code status, grpc_call *c, grpc_status_code status, const char *description,
const char *description,
gpr_uint8 locked); gpr_uint8 locked);
grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq, grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq,
@ -631,7 +630,8 @@ static int begin_message(grpc_call *call, grpc_begin_message msg) {
gpr_asprintf( gpr_asprintf(
&message, "Message terminated early; read %d bytes, expected %d", &message, "Message terminated early; read %d bytes, expected %d",
(int)call->incoming_message.length, (int)call->incoming_message_length); (int)call->incoming_message.length, (int)call->incoming_message_length);
grpc_call_cancel_with_status_internal(call, GRPC_STATUS_INVALID_ARGUMENT, message, 1); grpc_call_cancel_with_status_internal(call, GRPC_STATUS_INVALID_ARGUMENT,
message, 1);
gpr_free(message); gpr_free(message);
return 0; return 0;
} }
@ -642,7 +642,8 @@ static int begin_message(grpc_call *call, grpc_begin_message msg) {
&message, &message,
"Maximum message length of %d exceeded by a message of length %d", "Maximum message length of %d exceeded by a message of length %d",
grpc_channel_get_max_message_length(call->channel), msg.length); grpc_channel_get_max_message_length(call->channel), msg.length);
grpc_call_cancel_with_status_internal(call, GRPC_STATUS_INVALID_ARGUMENT, message, 1); grpc_call_cancel_with_status_internal(call, GRPC_STATUS_INVALID_ARGUMENT,
message, 1);
gpr_free(message); gpr_free(message);
return 0; return 0;
} else if (msg.length > 0) { } else if (msg.length > 0) {
@ -675,7 +676,8 @@ static int add_slice_to_message(grpc_call *call, gpr_slice slice) {
gpr_asprintf( gpr_asprintf(
&message, "Receiving message overflow; read %d bytes, expected %d", &message, "Receiving message overflow; read %d bytes, expected %d",
(int)call->incoming_message.length, (int)call->incoming_message_length); (int)call->incoming_message.length, (int)call->incoming_message_length);
grpc_call_cancel_with_status_internal(call, GRPC_STATUS_INVALID_ARGUMENT, message, 1); grpc_call_cancel_with_status_internal(call, GRPC_STATUS_INVALID_ARGUMENT,
message, 1);
gpr_free(message); gpr_free(message);
return 0; return 0;
} else if (call->incoming_message.length == call->incoming_message_length) { } else if (call->incoming_message.length == call->incoming_message_length) {
@ -1003,9 +1005,8 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *c,
return grpc_call_cancel_with_status_internal(c, status, description, 0); return grpc_call_cancel_with_status_internal(c, status, description, 0);
} }
static grpc_call_error grpc_call_cancel_with_status_internal(grpc_call *c, static grpc_call_error grpc_call_cancel_with_status_internal(
grpc_status_code status, grpc_call *c, grpc_status_code status, const char *description,
const char *description,
gpr_uint8 locked) { gpr_uint8 locked) {
grpc_transport_op op; grpc_transport_op op;
grpc_mdstr *details = grpc_mdstr *details =

@ -312,7 +312,8 @@ bool CallOpBuffer::FinalizeResult(void** tag, bool* status) {
got_message = *status; got_message = *status;
if (recv_message_) { if (recv_message_) {
GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, 0); GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, 0);
*status = *status && DeserializeProto(recv_buf_, recv_message_, max_message_size_); *status = *status &&
DeserializeProto(recv_buf_, recv_message_, max_message_size_);
grpc_byte_buffer_destroy(recv_buf_); grpc_byte_buffer_destroy(recv_buf_);
GRPC_TIMER_END(GRPC_PTAG_PROTO_DESERIALIZE, 0); GRPC_TIMER_END(GRPC_PTAG_PROTO_DESERIALIZE, 0);
} else { } else {
@ -343,7 +344,9 @@ Call::Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq)
Call::Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq, Call::Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq,
int max_message_size) int max_message_size)
: call_hook_(call_hook), cq_(cq), call_(call), : call_hook_(call_hook),
cq_(cq),
call_(call),
max_message_size_(max_message_size) {} max_message_size_(max_message_size) {}
void Call::PerformOps(CallOpBuffer* buffer) { void Call::PerformOps(CallOpBuffer* buffer) {

@ -126,7 +126,8 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
if (has_request_payload_) { if (has_request_payload_) {
GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, call_.call()); GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, call_.call());
req.reset(method_->AllocateRequestProto()); req.reset(method_->AllocateRequestProto());
if (!DeserializeProto(request_payload_, req.get(), call_.max_message_size())) { if (!DeserializeProto(request_payload_, req.get(),
call_.max_message_size())) {
// FIXME(yangg) deal with deserialization failure // FIXME(yangg) deal with deserialization failure
cq_.Shutdown(); cq_.Shutdown();
return; return;
@ -237,7 +238,7 @@ bool Server::RegisterAsyncService(AsynchronousService* service) {
GPR_ASSERT(service->dispatch_impl_ == nullptr && GPR_ASSERT(service->dispatch_impl_ == nullptr &&
"Can only register an asynchronous service against one server."); "Can only register an asynchronous service against one server.");
service->dispatch_impl_ = this; service->dispatch_impl_ = this;
service->request_args_ = new void* [service->method_count_]; service->request_args_ = new void*[service->method_count_];
for (size_t i = 0; i < service->method_count_; ++i) { for (size_t i = 0; i < service->method_count_; ++i) {
void* tag = void* tag =
grpc_server_register_method(server_, service->method_names_[i], nullptr, grpc_server_register_method(server_, service->method_names_[i], nullptr,
@ -364,8 +365,8 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
if (*status && request_) { if (*status && request_) {
if (payload_) { if (payload_) {
GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, call_); GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, call_);
*status = DeserializeProto(payload_, request_, *status =
server_->max_message_size_); DeserializeProto(payload_, request_, server_->max_message_size_);
GRPC_TIMER_END(GRPC_PTAG_PROTO_DESERIALIZE, call_); GRPC_TIMER_END(GRPC_PTAG_PROTO_DESERIALIZE, call_);
} else { } else {
*status = false; *status = false;

@ -37,6 +37,4 @@
#error "_SYS_SDT_H not defined, despite <sys/sdt.h> being present." #error "_SYS_SDT_H not defined, despite <sys/sdt.h> being present."
#endif #endif
int main() { int main() { return 0; }
return 0;
}

@ -182,7 +182,8 @@ class End2endTest : public ::testing::Test {
builder.AddListeningPort(server_address_.str(), builder.AddListeningPort(server_address_.str(),
InsecureServerCredentials()); InsecureServerCredentials());
builder.RegisterService(&service_); builder.RegisterService(&service_);
builder.SetMaxMessageSize(kMaxMessageSize_); // For testing max message size. builder.SetMaxMessageSize(
kMaxMessageSize_); // For testing max message size.
builder.RegisterService(&dup_pkg_service_); builder.RegisterService(&dup_pkg_service_);
builder.SetThreadPool(&thread_pool_); builder.SetThreadPool(&thread_pool_);
server_ = builder.BuildAndStart(); server_ = builder.BuildAndStart();
@ -428,8 +429,7 @@ TEST_F(End2endTest, DiffPackageServices) {
// rpc and stream should fail on bad credentials. // rpc and stream should fail on bad credentials.
TEST_F(End2endTest, BadCredentials) { TEST_F(End2endTest, BadCredentials) {
std::unique_ptr<Credentials> bad_creds = std::unique_ptr<Credentials> bad_creds = ServiceAccountCredentials("", "", 1);
ServiceAccountCredentials("", "", 1);
EXPECT_EQ(nullptr, bad_creds.get()); EXPECT_EQ(nullptr, bad_creds.get());
std::shared_ptr<ChannelInterface> channel = std::shared_ptr<ChannelInterface> channel =
CreateChannel(server_address_.str(), bad_creds, ChannelArguments()); CreateChannel(server_address_.str(), bad_creds, ChannelArguments());
@ -510,7 +510,6 @@ TEST_F(End2endTest, ClientCancelsRequestStream) {
EXPECT_EQ(grpc::StatusCode::CANCELLED, s.code()); EXPECT_EQ(grpc::StatusCode::CANCELLED, s.code());
EXPECT_EQ(response.message(), ""); EXPECT_EQ(response.message(), "");
} }
// Client cancels server stream after sending some messages // Client cancels server stream after sending some messages
@ -594,7 +593,7 @@ TEST_F(End2endTest, RpcMaxMessageSize) {
ResetStub(); ResetStub();
EchoRequest request; EchoRequest request;
EchoResponse response; EchoResponse response;
request.set_message(string(kMaxMessageSize_*2, 'a')); request.set_message(string(kMaxMessageSize_ * 2, 'a'));
ClientContext context; ClientContext context;
Status s = stub_->Echo(&context, request, &response); Status s = stub_->Echo(&context, request, &response);

Loading…
Cancel
Save