From 16110eee6a04b61bb69425221d6e52b641c05e33 Mon Sep 17 00:00:00 2001 From: Marek Gilbert Date: Tue, 26 Jan 2016 05:53:11 -0800 Subject: [PATCH 1/9] Allocate node Buffer contents with new[] Nan::NewBuffer(char* data, uint32_t size) frees the provided buffer by calling delete[]. This matches the allocation method to the free method. Fixes grpc/grpc#4867. --- src/node/ext/byte_buffer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index c306292c04c..4878219aca8 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -69,7 +69,7 @@ Local ByteBufferToBuffer(grpc_byte_buffer *buffer) { return scope.Escape(Nan::Null()); } size_t length = grpc_byte_buffer_length(buffer); - char *result = reinterpret_cast(calloc(length, sizeof(char))); + char *result = new char[length]; size_t offset = 0; grpc_byte_buffer_reader reader; grpc_byte_buffer_reader_init(&reader, buffer); From 0f14209061f79d37f4f72801d66c2ab68dc69b7f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 26 Jan 2016 14:20:07 -0800 Subject: [PATCH 2/9] Improve logging for test --- test/cpp/qps/driver.cc | 4 ++++ test/cpp/qps/qps_worker.cc | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index acb265b3086..1c4f3d0e568 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -161,6 +161,8 @@ std::unique_ptr RunScenario( // where class contained in std::vector must have a copy constructor auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { + gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", + workers[i].c_str(), i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; @@ -188,6 +190,8 @@ std::unique_ptr RunScenario( // where class contained in std::vector must have a copy constructor auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { + gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", + workers[i].c_str(), i); clients[i].stub = WorkerService::NewStub( CreateChannel(workers[i + num_servers], InsecureChannelCredentials())); ClientArgs args; diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index c0276d05b33..d8c8573a2cd 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -61,6 +61,11 @@ namespace grpc { namespace testing { static std::unique_ptr CreateClient(const ClientConfig& config) { + gpr_log(GPR_INFO, "Starting client of type %s %s %d", + ClientType_Name(config.client_type()).c_str(), + RpcType_Name(config.rpc_type()).c_str(), + config.payload_config().has_bytebuf_params()); + switch (config.client_type()) { case ClientType::SYNC_CLIENT: return (config.rpc_type() == RpcType::UNARY) @@ -81,6 +86,9 @@ static std::unique_ptr CreateClient(const ClientConfig& config) { static void LimitCores(int cores) {} static std::unique_ptr CreateServer(const ServerConfig& config) { + gpr_log(GPR_INFO, "Starting server of type %s", + ServerType_Name(config.server_type()).c_str()); + if (config.core_limit() > 0) { LimitCores(config.core_limit()); } @@ -169,22 +177,29 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (!args.has_setup()) { return Status(StatusCode::INVALID_ARGUMENT, ""); } + gpr_log(GPR_INFO, "RunClientBody: about to create client"); auto client = CreateClient(args.setup()); if (!client) { return Status(StatusCode::INVALID_ARGUMENT, ""); } + gpr_log(GPR_INFO, "RunClientBody: client created"); ClientStatus status; if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } + gpr_log(GPR_INFO, "RunClientBody: creation status reported\n"); while (stream->Read(&args)) { + gpr_log(GPR_INFO, "RunClientBody: Message read\n"); if (!args.has_mark()) { + gpr_log(GPR_INFO, "RunClientBody: Message is not a mark!\n"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = client->Mark(args.mark().reset()); stream->Write(status); + gpr_log(GPR_INFO, "RunClientBody: Mark response given\n"); } + gpr_log(GPR_INFO, "RunClientBody: Returning\n"); return Status::OK; } @@ -200,24 +215,31 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (server_port_ != 0) { args.mutable_setup()->set_port(server_port_); } + gpr_log(GPR_INFO, "RunServerBody: about to create server"); auto server = CreateServer(args.setup()); if (!server) { return Status(StatusCode::INVALID_ARGUMENT, ""); } + gpr_log(GPR_INFO, "RunServerBody: server created"); ServerStatus status; status.set_port(server->port()); status.set_cores(server->cores()); if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } + gpr_log(GPR_INFO, "RunServerBody: creation status reported\n"); while (stream->Read(&args)) { + gpr_log(GPR_INFO, "RunServerBody: Message read\n"); if (!args.has_mark()) { + gpr_log(GPR_INFO, "RunServerBody: Message not a mark!\n"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = server->Mark(args.mark().reset()); stream->Write(status); + gpr_log(GPR_INFO, "RunServerBody: Mark response given\n"); } + gpr_log(GPR_INFO, "RunServerBody: Returning\n"); return Status::OK; } From bdf4acbbfb4aafbe12073808f3a4dfffe0aad283 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 26 Jan 2016 15:15:26 -0800 Subject: [PATCH 3/9] Properly state client name --- test/cpp/qps/driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 1c4f3d0e568..daeb33a0aa1 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -191,7 +191,7 @@ std::unique_ptr RunScenario( auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", - workers[i].c_str(), i); + workers[i + num_servers].c_str(), i + num_servers); clients[i].stub = WorkerService::NewStub( CreateChannel(workers[i + num_servers], InsecureChannelCredentials())); ClientArgs args; From a091a23a7f10b6862c526f69bb5a8951d4365ecf Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 26 Jan 2016 18:10:42 -0800 Subject: [PATCH 4/9] No need to put \n at end of a log message --- test/cpp/qps/qps_worker.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index d8c8573a2cd..e782b2a6c5f 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -187,19 +187,19 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } - gpr_log(GPR_INFO, "RunClientBody: creation status reported\n"); + gpr_log(GPR_INFO, "RunClientBody: creation status reported"); while (stream->Read(&args)) { - gpr_log(GPR_INFO, "RunClientBody: Message read\n"); + gpr_log(GPR_INFO, "RunClientBody: Message read"); if (!args.has_mark()) { - gpr_log(GPR_INFO, "RunClientBody: Message is not a mark!\n"); + gpr_log(GPR_INFO, "RunClientBody: Message is not a mark!"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = client->Mark(args.mark().reset()); stream->Write(status); - gpr_log(GPR_INFO, "RunClientBody: Mark response given\n"); + gpr_log(GPR_INFO, "RunClientBody: Mark response given"); } - gpr_log(GPR_INFO, "RunClientBody: Returning\n"); + gpr_log(GPR_INFO, "RunClientBody: Returning"); return Status::OK; } @@ -227,19 +227,19 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } - gpr_log(GPR_INFO, "RunServerBody: creation status reported\n"); + gpr_log(GPR_INFO, "RunServerBody: creation status reported"); while (stream->Read(&args)) { - gpr_log(GPR_INFO, "RunServerBody: Message read\n"); + gpr_log(GPR_INFO, "RunServerBody: Message read"); if (!args.has_mark()) { - gpr_log(GPR_INFO, "RunServerBody: Message not a mark!\n"); + gpr_log(GPR_INFO, "RunServerBody: Message not a mark!"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = server->Mark(args.mark().reset()); stream->Write(status); - gpr_log(GPR_INFO, "RunServerBody: Mark response given\n"); + gpr_log(GPR_INFO, "RunServerBody: Mark response given"); } - gpr_log(GPR_INFO, "RunServerBody: Returning\n"); + gpr_log(GPR_INFO, "RunServerBody: Returning"); return Status::OK; } From 020c2f36ac7bec80a20c1acfe30d179902f77acd Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 26 Jan 2016 18:11:22 -0800 Subject: [PATCH 5/9] Fix copyright --- test/cpp/qps/driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index daeb33a0aa1..20d429751d0 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without From 94aada9ee5f35b5c1df6b103f3d8e8f24cbaaf70 Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 26 Jan 2016 18:12:30 -0800 Subject: [PATCH 6/9] clang-format --- test/cpp/qps/driver.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 20d429751d0..39b8f5cf0d7 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -161,8 +161,8 @@ std::unique_ptr RunScenario( // where class contained in std::vector must have a copy constructor auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { - gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", - workers[i].c_str(), i); + gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", workers[i].c_str(), + i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; From 17b5047e4627f6fc4e0229b2776f336a98ea3fdd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 27 Jan 2016 08:53:35 -0800 Subject: [PATCH 7/9] Fix copyrights --- include/grpc++/server.h | 2 +- tools/jenkins/grpc_interop_node/build_interop.sh | 2 +- tools/run_tests/build_node.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/grpc++/server.h b/include/grpc++/server.h index c9371ba6492..f24ed333bbb 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_node/build_interop.sh b/tools/jenkins/grpc_interop_node/build_interop.sh index 4d4290d0b41..526dd61fdfc 100755 --- a/tools/jenkins/grpc_interop_node/build_interop.sh +++ b/tools/jenkins/grpc_interop_node/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/run_tests/build_node.sh b/tools/run_tests/build_node.sh index b856b97942b..8f2ab4413a2 100755 --- a/tools/run_tests/build_node.sh +++ b/tools/run_tests/build_node.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without From 0c31b608058a36bd9d4163c72f666e94eb8442b0 Mon Sep 17 00:00:00 2001 From: vjpai Date: Wed, 27 Jan 2016 09:03:18 -0800 Subject: [PATCH 8/9] Sanity failures (copyright, clang-format) --- include/grpc++/server.h | 2 +- test/cpp/qps/driver.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grpc++/server.h b/include/grpc++/server.h index c9371ba6492..f24ed333bbb 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 39b8f5cf0d7..66269ae7578 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -162,7 +162,7 @@ std::unique_ptr RunScenario( auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", workers[i].c_str(), - i); + i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; From 59ab169ac10f759b0a60d3c803f80e2baf13ebed Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 27 Jan 2016 10:21:49 -0800 Subject: [PATCH 9/9] Fix copyrights --- src/node/ext/byte_buffer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index 4878219aca8..ee703fdc917 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without