From 922ea81877fc8b0676ae90d59a3caad9954e2feb Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Thu, 4 Jun 2015 17:32:31 -0700 Subject: [PATCH 001/124] QPS, latencies recorded with authentication --- Makefile | 39 +++++++--- build.json | 6 +- test/cpp/qps/report.cc | 103 +++++++++++++++++++++++++ test/cpp/qps/report.h | 14 ++++ test/cpp/qps/run_authenticated_test.sh | 87 +++++++++++++++++++++ test/cpp/qps/user_data.proto | 99 ++++++++++++++++++++++++ test/cpp/qps/user_data_client.cc | 100 ++++++++++++++++++++++++ test/cpp/qps/user_data_client.h | 88 +++++++++++++++++++++ test/cpp/util/benchmark_config.cc | 6 ++ 9 files changed, 532 insertions(+), 10 deletions(-) create mode 100755 test/cpp/qps/run_authenticated_test.sh create mode 100644 test/cpp/qps/user_data.proto create mode 100644 test/cpp/qps/user_data_client.cc create mode 100644 test/cpp/qps/user_data_client.h diff --git a/Makefile b/Makefile index 13170c7227a..fbe2e4c3c2c 100644 --- a/Makefile +++ b/Makefile @@ -2457,6 +2457,21 @@ $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc: test/cpp/qps/qpstest.proto $(PROTOBUF $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $< endif +ifeq ($(NO_PROTOC),true) +$(GENDIR)/test/cpp/qps/user_data.pb.cc: protoc_dep_error +$(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc: protoc_dep_error +else +$(GENDIR)/test/cpp/qps/user_data.pb.cc: test/cpp/qps/user_data.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[PROTOC] Generating protobuf CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) --cpp_out=$(GENDIR) $< + +$(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc: test/cpp/qps/user_data.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $< +endif + ifeq ($(NO_PROTOC),true) $(GENDIR)/test/cpp/util/echo.pb.cc: protoc_dep_error $(GENDIR)/test/cpp/util/echo.grpc.pb.cc: protoc_dep_error @@ -3452,7 +3467,9 @@ endif LIBGRPC++_BENCHMARK_CONFIG_SRC = \ $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc \ + $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc \ test/cpp/qps/report.cc \ + test/cpp/qps/user_data_client.cc \ test/cpp/util/benchmark_config.cc \ @@ -3497,8 +3514,9 @@ ifneq ($(NO_DEPS),true) -include $(LIBGRPC++_BENCHMARK_CONFIG_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/user_data_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc LIBGRPC++_TEST_CONFIG_SRC = \ @@ -4011,6 +4029,7 @@ $(OBJDIR)/$(CONFIG)/examples/pubsub/subscriber.o: $(GENDIR)/examples/pubsub/labe LIBQPS_SRC = \ $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc \ + $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc \ test/cpp/qps/client_async.cc \ test/cpp/qps/client_sync.cc \ test/cpp/qps/driver.cc \ @@ -4018,6 +4037,7 @@ LIBQPS_SRC = \ test/cpp/qps/server_async.cc \ test/cpp/qps/server_sync.cc \ test/cpp/qps/timer.cc \ + test/cpp/qps/user_data_client.cc \ LIBQPS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBQPS_SRC)))) @@ -4061,13 +4081,14 @@ ifneq ($(NO_DEPS),true) -include $(LIBQPS_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/user_data_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc LIBGRPC_CSHARP_EXT_SRC = \ diff --git a/build.json b/build.json index 084645937b7..0b68f876f9f 100644 --- a/build.json +++ b/build.json @@ -537,7 +537,9 @@ "language": "c++", "src": [ "test/cpp/qps/qpstest.proto", + "test/cpp/qps/user_data.proto", "test/cpp/qps/report.cc", + "test/cpp/qps/user_data_client.cc", "test/cpp/util/benchmark_config.cc" ] }, @@ -707,13 +709,15 @@ ], "src": [ "test/cpp/qps/qpstest.proto", + "test/cpp/qps/user_data.proto", "test/cpp/qps/client_async.cc", "test/cpp/qps/client_sync.cc", "test/cpp/qps/driver.cc", "test/cpp/qps/qps_worker.cc", "test/cpp/qps/server_async.cc", "test/cpp/qps/server_sync.cc", - "test/cpp/qps/timer.cc" + "test/cpp/qps/timer.cc", + "test/cpp/qps/user_data_client.cc" ], "deps": [ "grpc_test_util", diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index e116175e3b3..b4229889add 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -35,6 +35,7 @@ #include #include "test/cpp/qps/stats.h" +#include "user_data_client.h" namespace grpc { namespace testing { @@ -120,5 +121,107 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) const { [](ResourceUsage u) { return u.wall_time; })); } +UserDataClient userDataClient(grpc::CreateChannel("localhost:50052", grpc::InsecureCredentials(), + ChannelArguments())); + +//Leaderboard Reported implementation. +void UserDatabaseReporter::ReportQPS(const ScenarioResult& result) const { + double qps = result.latencies.Count() / + average(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); + + userDataClient.setAccessToken(access_token_); + userDataClient.setQPS(qps); + + int userDataState = userDataClient.sendDataIfReady(); + + switch(userDataState) { + case 1: + gpr_log(GPR_INFO, "Data sent to user database successfully"); + break; + case -1: + gpr_log(GPR_INFO, "Data could not be sent to user database"); + break; + } +} + +void UserDatabaseReporter::ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& server_config) const { + double qps = result.latencies.Count() / + average(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); + + double qpsPerCore = qps / server_config.threads(); + + userDataClient.setAccessToken(access_token_); + //TBD + userDataClient.setQPSPerCore(qpsPerCore); + + int userDataState = userDataClient.sendDataIfReady(); + + switch(userDataState) { + case 1: + gpr_log(GPR_INFO, "Data sent to user database successfully"); + break; + case -1: + gpr_log(GPR_INFO, "Data could not be sent to user database"); + break; + } +} + +void UserDatabaseReporter::ReportLatency(const ScenarioResult& result) const { + userDataClient.setAccessToken(access_token_); + userDataClient.setLatencies(result.latencies.Percentile(50) / 1000, + result.latencies.Percentile(90) / 1000, + result.latencies.Percentile(95) / 1000, + result.latencies.Percentile(99) / 1000, + result.latencies.Percentile(99.9) / 1000); + + int userDataState = userDataClient.sendDataIfReady(); + + switch(userDataState) { + case 1: + gpr_log(GPR_INFO, "Data sent to user database successfully"); + break; + case -1: + gpr_log(GPR_INFO, "Data could not be sent to user database"); + break; + } +} + +void UserDatabaseReporter::ReportTimes(const ScenarioResult& result) const { + double serverSystemTime = 100.0 * sum(result.server_resources, + [](ResourceUsage u) { return u.system_time; }) / + sum(result.server_resources, + [](ResourceUsage u) { return u.wall_time; }); + double serverUserTime = 100.0 * sum(result.server_resources, + [](ResourceUsage u) { return u.user_time; }) / + sum(result.server_resources, + [](ResourceUsage u) { return u.wall_time; }); + double clientSystemTime = 100.0 * sum(result.client_resources, + [](ResourceUsage u) { return u.system_time; }) / + sum(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); + double clientUserTime = 100.0 * sum(result.client_resources, + [](ResourceUsage u) { return u.user_time; }) / + sum(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); + + userDataClient.setAccessToken(access_token_); + userDataClient.setTimes(serverSystemTime, serverUserTime, + clientSystemTime, clientUserTime); + + int userDataState = userDataClient.sendDataIfReady(); + + switch(userDataState) { + case 1: + gpr_log(GPR_INFO, "Data sent to user database successfully"); + break; + case -1: + gpr_log(GPR_INFO, "Data could not be sent to user database"); + break; + } +} + } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 630275ecda2..2e5b627e581 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -106,6 +106,20 @@ class GprLogReporter : public Reporter { void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; }; +/** Reporter for client leaderboard. */ +class UserDatabaseReporter : public Reporter { + public: + UserDatabaseReporter(const string& name, const string& access_token) : Reporter(name), access_token_(access_token) {} + + private: + std::string access_token_; + void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const GRPC_OVERRIDE; + void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; +}; + } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/run_authenticated_test.sh b/test/cpp/qps/run_authenticated_test.sh new file mode 100755 index 00000000000..3cde6494142 --- /dev/null +++ b/test/cpp/qps/run_authenticated_test.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +CLIENT_ID='1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' +CLIENT_SECRET='_HGHXg4DAA59r4w4x8p6ARzD' +GRANT_TYPE='http://oauth.net/grant_type/device/1.0' +ACCESS_TOKENS_DIR='/tmp/auth_lead_access_tokens' +AUTH_TOKEN_LINK='https://www.googleapis.com/oauth2/v3/token' +GOOGLE_ACCOUNTS_LINK='https://accounts.google.com/o/oauth2/device/code' +USER_INFO_LINK='https://www.googleapis.com/oauth2/v1/userinfo' +#Performs first time authentication +#Or re-authentication if refresh token expires +RE_AUTHENTICATE() { + INIT_AUTH_JSON=$(curl -s -d "client_id=$CLIENT_ID&scope=email profile" $GOOGLE_ACCOUNTS_LINK) + + USER_CODE=$(echo $INIT_AUTH_JSON | jq .user_code | sed -e 's/^"//' -e 's/"$//') + echo 'Please use the following user code in the browser:' $USER_CODE + echo + + VERIFICATION_URL=$(echo $INIT_AUTH_JSON | jq '.verification_url' | sed -e 's/^"//' -e 's/"$//') + echo 'Verification URL:' $VERIFICATION_URL + echo + + xdg-open $VERIFICATION_URL + + DEVICE_CODE=$(echo $INIT_AUTH_JSON | jq '.device_code' | sed -e 's/^"//' -e 's/"$//') + INTERVAL=$(echo $INIT_AUTH_JSON | jq '.interval' | sed -e 's/^"//' -e 's/"$//') + + AUTH_JSON=$(curl -s -d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&code=$DEVICE_CODE&grant_type=$GRANT_TYPE" $AUTH_TOKEN_LINK) + ACCESS_TOKEN=$(echo $AUTH_JSON | jq '.access_token' | sed -e 's/^"//' -e 's/"$//') + + while [ $ACCESS_TOKEN == 'null' ] + do + sleep $INTERVAL + AUTH_JSON=$(curl -s -d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&code=$DEVICE_CODE&grant_type=$GRANT_TYPE" $AUTH_TOKEN_LINK) + ACCESS_TOKEN=$(echo $AUTH_JSON | jq '.access_token' | sed -e 's/^"//' -e 's/"$//') + done + + USER_DETAILS=$(curl -s $USER_INFO_LINK?access_token=$ACCESS_TOKEN) + USER_ID=$(echo $USER_DETAILS | jq '.email' | sed -e 's/^"//' -e 's/"$//' | awk -F"@" '{print $1}' | sed -e 's/\.//g' | awk '{print tolower($0)}') + echo $AUTH_JSON > $ACCESS_TOKENS_DIR/$USER_ID +} + +#Use existing access token +USE_ACCESS_TOKEN() { + ACCESS_TOKEN=$(jq '.access_token' $ACCESS_TOKENS_DIR/$USER_ID | sed -e 's/^"//' -e 's/"$//') + + USER_DETAILS=$(curl -s $USER_INFO_LINK?access_token=$ACCESS_TOKEN) + + ID=$(echo $USER_DETAILS | jq '.id' | sed -e 's/^"//' -e 's/"$//') + + if [ $ID == 'null' ]; then + REFRESH_ACCESS_TOKEN + fi +} + +#Obtain new access token using refresh token +REFRESH_ACCESS_TOKEN() { + REFRESH_TOKEN=$(jq '.refresh_token' $ACCESS_TOKENS_DIR/$USER_ID | sed -e 's/^"//' -e 's/"$//') + if [ $REFRESH_TOKEN == 'null' ]; then + RE_AUTHENTICATE + else + REFRESH_JSON=$(curl -s -d "refresh_token=$REFRESH_TOKEN&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=refresh_token" $AUTH_TOKEN_LINK) + + ACCESS_TOKEN=$(echo $REFRESH_JSON | jq '.access_token') + if [ $ACCESS_TOKEN == 'null' ]; then + RE_AUTHENTICATE + else + NEW_AUTH_JSON=$(jq ".access_token=$ACCESS_TOKEN" $ACCESS_TOKENS_DIR/$USER_ID) + echo $NEW_AUTH_JSON > $ACCESS_TOKENS_DIR/$USER_ID + fi + fi +} + +#create directory to store tokens, if not already present +[ ! -d $ACCESS_TOKENS_DIR ] && mkdir $ACCESS_TOKENS_DIR + +#Convert user entered email id to unique string by converting to splitting on '@' symbol, if present, +#removing '.'s and converting to lowercase +USER_ID=$(echo $2 | awk -F"@" '{print $1}' | sed -e 's/\.//g' | awk '{print tolower($0)}') + +if [ -s $ACCESS_TOKENS_DIR/$USER_ID ]; then + USE_ACCESS_TOKEN +else + RE_AUTHENTICATE +fi + +./$1 --access_token=$ACCESS_TOKEN \ No newline at end of file diff --git a/test/cpp/qps/user_data.proto b/test/cpp/qps/user_data.proto new file mode 100644 index 00000000000..9c941cae2c5 --- /dev/null +++ b/test/cpp/qps/user_data.proto @@ -0,0 +1,99 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto2"; + +package UserData; + +service UserDataTransfer { + // Sends client info + rpc RecordSingleClientData (SingleUserRecordRequest) returns (SingleUserRecordReply) {} + + rpc RetrieveSingleUserData (SingleUserRetrieveRequest) returns (SingleUserRetrieveReply) {} + + rpc RetrieveAllUsersData (AllUsersRetrieveRequest) returns (AllUsersRetrieveReply) {} +} + +//Metrics to be stored +message Metrics { + required double qps = 1; + required double perc_lat_50 = 2; + required double perc_lat_90 = 3; + required double perc_lat_95 = 4; + required double perc_lat_99 = 5; + required double perc_lat_99_point_9 = 6; +} + +//Timestamped details +message DataDetails { + required string timestamp = 1; + required Metrics metrics = 2; +} + +//User details +message UserDetails { + required string id = 1; + required string name = 2; + required string link = 3; +} + +//Stored to database +message SingleUserDetails { + repeated DataDetails data_details = 1; + required UserDetails user_details = 2; +} + +//Request for storing a single user's data +message SingleUserRecordRequest { + required string access_token = 1; + required Metrics metrics = 2; +} + +//Reply to request for storing single user's data +message SingleUserRecordReply { +} + +//Request for retrieving single user's data +message SingleUserRetrieveRequest { + required string client_id = 1; +} + +//Reply for request to retrieve single user's data +message SingleUserRetrieveReply { + required SingleUserDetails details = 1; +} + +//Request for retrieving all users' data +message AllUsersRetrieveReply { + repeated SingleUserDetails user_data = 1; +} + +//Reply to request for retrieving all users' data +message AllUsersRetrieveRequest { +} \ No newline at end of file diff --git a/test/cpp/qps/user_data_client.cc b/test/cpp/qps/user_data_client.cc new file mode 100644 index 00000000000..20ce6d9c09e --- /dev/null +++ b/test/cpp/qps/user_data_client.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "user_data_client.h" + +void UserDataClient::setAccessToken(std::string access_token) { + access_token_ = access_token; +} + +void UserDataClient::setQPS(double QPS) { + QPS_ = QPS; + qpsSet = true; +} + +void UserDataClient::setQPSPerCore(double qpsPerCore) { + //TBD +} + +void UserDataClient::setLatencies(double percentileLatency50, double percentileLatency90, + double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) { + percentileLatency50_ = percentileLatency50; + percentileLatency90_ = percentileLatency90; + percentileLatency95_ = percentileLatency95; + percentileLatency99_ = percentileLatency99; + percentileLatency99Point9_ = percentileLatency99Point9; + + latenciesSet = true; +} + +void UserDataClient::setTimes(double serverSystemTime, double serverUserTime, + double clientSystemTime, double clientUserTime) { + //TBD +} + +int UserDataClient::sendDataIfReady() { + if(!(qpsSet && latenciesSet)) + return 0; + + SingleUserRecordRequest singleUserRecordRequest; + singleUserRecordRequest.set_access_token(access_token_); + + Metrics* metrics = singleUserRecordRequest.mutable_metrics(); + metrics->set_qps(QPS_); + metrics->set_perc_lat_50(percentileLatency50_); + metrics->set_perc_lat_90(percentileLatency90_); + metrics->set_perc_lat_95(percentileLatency95_); + metrics->set_perc_lat_99(percentileLatency99_); + metrics->set_perc_lat_99_point_9(percentileLatency99Point9_); + + SingleUserRecordReply singleUserRecordReply; + ClientContext context; + + Status status = stub_->RecordSingleClientData(&context, singleUserRecordRequest, &singleUserRecordReply); + if (status.IsOk()) { + return 1; + } else { + return -1; + } +} + +// Get current date/time, format is YYYY-MM-DD.HH:mm:ss +const std::string currentDateTime() { + time_t now = time(0); + struct tm tstruct; + char buf[80]; + tstruct = *localtime(&now); + + strftime(buf, sizeof(buf), "%Y/%m/%d, %X", &tstruct); + return buf; +} \ No newline at end of file diff --git a/test/cpp/qps/user_data_client.h b/test/cpp/qps/user_data_client.h new file mode 100644 index 00000000000..ec3dcb5d44b --- /dev/null +++ b/test/cpp/qps/user_data_client.h @@ -0,0 +1,88 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include "test/cpp/qps/user_data.grpc.pb.h" + +using grpc::ChannelArguments; +using grpc::ChannelInterface; +using grpc::ClientContext; +using grpc::Status; +using UserData::UserDataTransfer; +using UserData::Metrics; +using UserData::SingleUserRecordRequest; +using UserData::SingleUserRecordReply; + +class UserDataClient { + public: + UserDataClient(std::shared_ptr channel) + : stub_(UserDataTransfer::NewStub(channel)) {} + + ~UserDataClient() {} + + void setAccessToken(std::string access_token); + + void setQPS(double QPS); + + void setQPSPerCore(double qpsPerCore); + + void setLatencies(double percentileLatency50, double percentileLatency90, + double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); + + void setTimes(double serverSystemTime, double serverUserTime, + double clientSystemTime, double clientUserTime); + + int sendDataIfReady(); + + private: + std::unique_ptr stub_; + std::string access_token_; + double QPS_; + double percentileLatency50_; + double percentileLatency90_; + double percentileLatency95_; + double percentileLatency99_; + double percentileLatency99Point9_; + bool qpsSet = false; + bool latenciesSet = false; +}; \ No newline at end of file diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 5b3c1daf5db..b68822436db 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -37,6 +37,8 @@ DEFINE_bool(enable_log_reporter, true, "Enable reporting of benchmark results through GprLog"); +DEFINE_string(access_token, "", "Authorizing JSON string for leaderboard"); + // In some distros, gflags is in the namespace google, and in some others, // in gflags. This hack is enabling us to find both. namespace google {} @@ -57,6 +59,10 @@ static std::shared_ptr InitBenchmarkReporters() { composite_reporter->add( std::unique_ptr(new GprLogReporter("LogReporter"))); } + if(!FLAGS_access_token.empty()) + composite_reporter->add( + std::unique_ptr(new UserDatabaseReporter("UserDataReporter", FLAGS_access_token))); + return std::shared_ptr(composite_reporter); } From 39824335ea2d29ab627a8accb8e12c3bd50352ad Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 8 Jun 2015 13:44:51 -0700 Subject: [PATCH 002/124] Newer version --- test/cpp/qps/report.cc | 54 +++--------- test/cpp/qps/report.h | 6 +- test/cpp/qps/run_auth_test.py | 135 ++++++++++++++++++++++++++++++ test/cpp/qps/user_data.proto | 55 ++++++++---- test/cpp/qps/user_data_client.cc | 62 ++++++++------ test/cpp/qps/user_data_client.h | 51 ++++++----- test/cpp/util/benchmark_config.cc | 4 +- 7 files changed, 258 insertions(+), 109 deletions(-) create mode 100644 test/cpp/qps/run_auth_test.py diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index b4229889add..124bdc70fdc 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -130,19 +130,8 @@ void UserDatabaseReporter::ReportQPS(const ScenarioResult& result) const { average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - userDataClient.setAccessToken(access_token_); userDataClient.setQPS(qps); - - int userDataState = userDataClient.sendDataIfReady(); - - switch(userDataState) { - case 1: - gpr_log(GPR_INFO, "Data sent to user database successfully"); - break; - case -1: - gpr_log(GPR_INFO, "Data could not be sent to user database"); - break; - } + userDataClient.setConfigs(result.client_config, result.server_config); } void UserDatabaseReporter::ReportQPSPerCore(const ScenarioResult& result, @@ -153,40 +142,17 @@ void UserDatabaseReporter::ReportQPSPerCore(const ScenarioResult& result, double qpsPerCore = qps / server_config.threads(); - userDataClient.setAccessToken(access_token_); - //TBD userDataClient.setQPSPerCore(qpsPerCore); - - int userDataState = userDataClient.sendDataIfReady(); - - switch(userDataState) { - case 1: - gpr_log(GPR_INFO, "Data sent to user database successfully"); - break; - case -1: - gpr_log(GPR_INFO, "Data could not be sent to user database"); - break; - } + userDataClient.setConfigs(result.client_config, result.server_config); } void UserDatabaseReporter::ReportLatency(const ScenarioResult& result) const { - userDataClient.setAccessToken(access_token_); userDataClient.setLatencies(result.latencies.Percentile(50) / 1000, - result.latencies.Percentile(90) / 1000, - result.latencies.Percentile(95) / 1000, - result.latencies.Percentile(99) / 1000, - result.latencies.Percentile(99.9) / 1000); - - int userDataState = userDataClient.sendDataIfReady(); - - switch(userDataState) { - case 1: - gpr_log(GPR_INFO, "Data sent to user database successfully"); - break; - case -1: - gpr_log(GPR_INFO, "Data could not be sent to user database"); - break; - } + result.latencies.Percentile(90) / 1000, + result.latencies.Percentile(95) / 1000, + result.latencies.Percentile(99) / 1000, + result.latencies.Percentile(99.9) / 1000); + userDataClient.setConfigs(result.client_config, result.server_config); } void UserDatabaseReporter::ReportTimes(const ScenarioResult& result) const { @@ -207,11 +173,13 @@ void UserDatabaseReporter::ReportTimes(const ScenarioResult& result) const { sum(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - userDataClient.setAccessToken(access_token_); userDataClient.setTimes(serverSystemTime, serverUserTime, clientSystemTime, clientUserTime); + userDataClient.setConfigs(result.client_config, result.server_config); +} - int userDataState = userDataClient.sendDataIfReady(); +void UserDatabaseReporter::Flush() const { + int userDataState = userDataClient.sendData(access_token_, test_name_); switch(userDataState) { case 1: diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 2e5b627e581..8a1ce2dabc3 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -109,15 +109,19 @@ class GprLogReporter : public Reporter { /** Reporter for client leaderboard. */ class UserDatabaseReporter : public Reporter { public: - UserDatabaseReporter(const string& name, const string& access_token) : Reporter(name), access_token_(access_token) {} + UserDatabaseReporter(const string& name, const string& access_token, + const string& test_name) : Reporter(name), access_token_(access_token), test_name_(test_name) {} + ~UserDatabaseReporter() { Flush(); }; private: std::string access_token_; + std::string test_name_; void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; void ReportQPSPerCore(const ScenarioResult& result, const ServerConfig& config) const GRPC_OVERRIDE; void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; + void Flush() const; }; } // namespace testing diff --git a/test/cpp/qps/run_auth_test.py b/test/cpp/qps/run_auth_test.py new file mode 100644 index 00000000000..3ed2a7c9804 --- /dev/null +++ b/test/cpp/qps/run_auth_test.py @@ -0,0 +1,135 @@ +#!/usr/bin/python + +import os +import sys +import re +import urllib2 +import urllib +import json +import time +import subprocess + +CLIENT_ID = '1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' +CLIENT_SECRET = '_HGHXg4DAA59r4w4x8p6ARzD' +GRANT_TYPE = 'http://oauth.net/grant_type/device/1.0' +ACCESS_TOKENS_DIR = '/tmp/auth_lead_access_tokens' +AUTH_TOKEN_LINK = 'https://www.googleapis.com/oauth2/v3/token' +GOOGLE_ACCOUNTS_LINK = 'https://accounts.google.com/o/oauth2/device/code' +USER_INFO_LINK = 'https://www.googleapis.com/oauth2/v1/userinfo' + +def fetchJSON(url, paramDict): + if len(paramDict) == 0: + req = urllib2.Request(url) + else: + data = urllib.urlencode(paramDict) + req = urllib2.Request(url, data) + + try: + response = urllib2.urlopen(req) + result = response.read() + + except urllib2.HTTPError, error: + result = error.read() + + return result + +def getUserInfo(accessToken): + url = USER_INFO_LINK + '?access_token=' + accessToken + paramDict = {} + JSONBody = fetchJSON(url, paramDict) + data = json.loads(JSONBody) + + return data + +def isAccessTokenValid(accessToken): + data = getUserInfo(accessToken); + + if 'id' in data: + return True + else: + return False + +def getUserId(accessToken): + data = getUserInfo(accessToken) + + email = data['email'] + email = email.split('@')[0].lower() + userId = re.sub('[.]', '', email) + + return userId + +def useAccessToken(userTokFile): + with open(userTokFile, "r") as data_file: + data = json.load(data_file) + accessToken = data["access_token"] + + if not isAccessTokenValid(accessToken): + return refreshAccessToken(data["refresh_token"], userTokFile) + + return accessToken + +def refreshAccessToken(refreshToken, userTokFile): + paramDict = {'refresh_token':refreshToken, 'client_id':CLIENT_ID, 'client_secret':CLIENT_SECRET, 'grant_type':'refresh_token'} + JSONBody = fetchJSON(AUTH_TOKEN_LINK, paramDict) + data = json.loads(JSONBody) + if not 'access_token' in data: + return reauthenticate() + else: + tokenData = {} + + with open(userTokFile, "r") as data_file: + tokenData = json.load(data_file) + + with open(userTokFile, "w") as data_file: + tokenData['access_token'] = data['access_token'] + json.dump(tokenData, data_file) + + return data['access_token'] + +def reauthenticate(): + paramDict = {'client_id':CLIENT_ID, 'scope':'email profile'} + JSONBody = fetchJSON(GOOGLE_ACCOUNTS_LINK, paramDict) + data = json.loads(JSONBody) + + print 'User authorization required\n' + print 'Please use the following code in you browser: ', data['user_code'] + print 'Verification URL: ', data['verification_url'] + print '\nAwaiting user authorization. May take a few more seconds after authorizing...\n' + + authData = {} + + while not 'access_token' in authData: + authDict = {'client_id':CLIENT_ID, 'client_secret':CLIENT_SECRET, 'code':data['device_code'], 'grant_type':GRANT_TYPE} + JSONBody = fetchJSON(AUTH_TOKEN_LINK, authDict) + authData = json.loads(JSONBody) + time.sleep(data['interval']) + + newUserTokFile = ACCESS_TOKENS_DIR + '/' + getUserId(authData['access_token']) + + with open(newUserTokFile, "w") as data_file: + json.dump(authData, data_file) + + return authData['access_token'] + +def main(): + if not os.path.exists(ACCESS_TOKENS_DIR): + os.makedirs(ACCESS_TOKENS_DIR) + + email = sys.argv[2] + email = email.split('@')[0].lower() + userId = re.sub('[.]', '', email) + + userTokFile = ACCESS_TOKENS_DIR + '/' + userId + + accessToken = '' + + if os.path.exists(userTokFile): + accessToken = useAccessToken(userTokFile) + else: + accessToken = reauthenticate() + + testName = sys.argv[1].split('/')[-1] + subprocess.call([sys.argv[1], '--access_token='+accessToken, '--test_name='+testName]) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/test/cpp/qps/user_data.proto b/test/cpp/qps/user_data.proto index 9c941cae2c5..27d0049cf07 100644 --- a/test/cpp/qps/user_data.proto +++ b/test/cpp/qps/user_data.proto @@ -29,7 +29,9 @@ syntax = "proto2"; -package UserData; +import "test/cpp/qps/qpstest.proto"; + +package grpc.testing; service UserDataTransfer { // Sends client info @@ -42,37 +44,56 @@ service UserDataTransfer { //Metrics to be stored message Metrics { - required double qps = 1; - required double perc_lat_50 = 2; - required double perc_lat_90 = 3; - required double perc_lat_95 = 4; - required double perc_lat_99 = 5; - required double perc_lat_99_point_9 = 6; + optional double qps = 1; + optional double qps_per_core = 2; + optional double perc_lat_50 = 3; + optional double perc_lat_90 = 4; + optional double perc_lat_95 = 5; + optional double perc_lat_99 = 6; + optional double perc_lat_99_point_9 = 7; + optional double server_system_time = 8; + optional double server_user_time = 9; + optional double client_system_time = 10; + optional double client_user_time = 11; } //Timestamped details message DataDetails { - required string timestamp = 1; - required Metrics metrics = 2; + optional string timestamp = 1; + optional string test_name = 2; + optional Metrics metrics = 3; + optional ClientConfig client_config = 4; + optional ServerConfig server_config = 5; } //User details message UserDetails { - required string id = 1; - required string name = 2; - required string link = 3; + optional string id = 1; + optional string email = 2; + optional bool verified_email = 3; + optional string name = 4; + optional string given_name = 5; + optional string family_name = 6; + optional string link = 7; + optional string picture = 8; + optional string gender = 9; + optional string locale = 10; + optional string hd = 11; } //Stored to database message SingleUserDetails { repeated DataDetails data_details = 1; - required UserDetails user_details = 2; + optional UserDetails user_details = 2; } //Request for storing a single user's data message SingleUserRecordRequest { - required string access_token = 1; - required Metrics metrics = 2; + optional string access_token = 1; + optional string test_name = 2; + optional Metrics metrics = 3; + optional ClientConfig client_config = 4; + optional ServerConfig server_config = 5; } //Reply to request for storing single user's data @@ -81,12 +102,12 @@ message SingleUserRecordReply { //Request for retrieving single user's data message SingleUserRetrieveRequest { - required string client_id = 1; + optional string user_id = 1; } //Reply for request to retrieve single user's data message SingleUserRetrieveReply { - required SingleUserDetails details = 1; + optional SingleUserDetails details = 1; } //Request for retrieving all users' data diff --git a/test/cpp/qps/user_data_client.cc b/test/cpp/qps/user_data_client.cc index 20ce6d9c09e..50b74276d2e 100644 --- a/test/cpp/qps/user_data_client.cc +++ b/test/cpp/qps/user_data_client.cc @@ -33,17 +33,20 @@ #include "user_data_client.h" -void UserDataClient::setAccessToken(std::string access_token) { - access_token_ = access_token; +namespace grpc { +namespace testing { + +void UserDataClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) { + clientConfig_ = clientConfig; + serverConfig_ = serverConfig; } void UserDataClient::setQPS(double QPS) { QPS_ = QPS; - qpsSet = true; } -void UserDataClient::setQPSPerCore(double qpsPerCore) { - //TBD +void UserDataClient::setQPSPerCore(double QPSPerCore) { + QPSPerCore_ = QPSPerCore; } void UserDataClient::setLatencies(double percentileLatency50, double percentileLatency90, @@ -53,29 +56,37 @@ void UserDataClient::setLatencies(double percentileLatency50, double percentileL percentileLatency95_ = percentileLatency95; percentileLatency99_ = percentileLatency99; percentileLatency99Point9_ = percentileLatency99Point9; - - latenciesSet = true; } void UserDataClient::setTimes(double serverSystemTime, double serverUserTime, double clientSystemTime, double clientUserTime) { - //TBD + serverSystemTime_ = serverSystemTime; + serverUserTime_ = serverUserTime; + clientSystemTime_ = clientSystemTime; + clientUserTime_ = clientUserTime; } -int UserDataClient::sendDataIfReady() { - if(!(qpsSet && latenciesSet)) - return 0; +int UserDataClient::sendData(std::string access_token, std::string test_name) { SingleUserRecordRequest singleUserRecordRequest; - singleUserRecordRequest.set_access_token(access_token_); + singleUserRecordRequest.set_access_token(access_token); + singleUserRecordRequest.set_test_name(test_name); + *(singleUserRecordRequest.mutable_client_config()) = clientConfig_; + *(singleUserRecordRequest.mutable_server_config()) = serverConfig_; Metrics* metrics = singleUserRecordRequest.mutable_metrics(); - metrics->set_qps(QPS_); - metrics->set_perc_lat_50(percentileLatency50_); - metrics->set_perc_lat_90(percentileLatency90_); - metrics->set_perc_lat_95(percentileLatency95_); - metrics->set_perc_lat_99(percentileLatency99_); - metrics->set_perc_lat_99_point_9(percentileLatency99Point9_); + + if(QPS_ != DBL_MIN) metrics->set_qps(QPS_); + if(QPSPerCore_ != DBL_MIN) metrics->set_qps_per_core(QPSPerCore_); + if(percentileLatency50_ != DBL_MIN) metrics->set_perc_lat_50(percentileLatency50_); + if(percentileLatency90_ != DBL_MIN) metrics->set_perc_lat_90(percentileLatency90_); + if(percentileLatency95_ != DBL_MIN) metrics->set_perc_lat_95(percentileLatency95_); + if(percentileLatency99_ != DBL_MIN) metrics->set_perc_lat_99(percentileLatency99_); + if(percentileLatency99Point9_ != DBL_MIN) metrics->set_perc_lat_99_point_9(percentileLatency99Point9_); + if(serverSystemTime_ != DBL_MIN) metrics->set_server_system_time(serverSystemTime_); + if(serverUserTime_ != DBL_MIN) metrics->set_server_user_time(serverUserTime_); + if(clientSystemTime_ != DBL_MIN) metrics->set_client_system_time(clientSystemTime_); + if(clientUserTime_ != DBL_MIN) metrics->set_client_user_time(clientUserTime_); SingleUserRecordReply singleUserRecordReply; ClientContext context; @@ -90,11 +101,14 @@ int UserDataClient::sendDataIfReady() { // Get current date/time, format is YYYY-MM-DD.HH:mm:ss const std::string currentDateTime() { - time_t now = time(0); - struct tm tstruct; - char buf[80]; - tstruct = *localtime(&now); + time_t now = time(0); + struct tm tstruct; + char buf[80]; + tstruct = *localtime(&now); - strftime(buf, sizeof(buf), "%Y/%m/%d, %X", &tstruct); - return buf; + strftime(buf, sizeof(buf), "%Y/%m/%d, %X", &tstruct); + return buf; +} + +} } \ No newline at end of file diff --git a/test/cpp/qps/user_data_client.h b/test/cpp/qps/user_data_client.h index ec3dcb5d44b..0186ec90712 100644 --- a/test/cpp/qps/user_data_client.h +++ b/test/cpp/qps/user_data_client.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -44,27 +45,22 @@ #include #include "test/cpp/qps/user_data.grpc.pb.h" -using grpc::ChannelArguments; -using grpc::ChannelInterface; -using grpc::ClientContext; -using grpc::Status; -using UserData::UserDataTransfer; -using UserData::Metrics; -using UserData::SingleUserRecordRequest; -using UserData::SingleUserRecordReply; + +namespace grpc{ +namespace testing { class UserDataClient { - public: +public: UserDataClient(std::shared_ptr channel) : stub_(UserDataTransfer::NewStub(channel)) {} ~UserDataClient() {} - void setAccessToken(std::string access_token); + void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig); void setQPS(double QPS); - void setQPSPerCore(double qpsPerCore); + void setQPSPerCore(double QPSPerCore); void setLatencies(double percentileLatency50, double percentileLatency90, double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); @@ -72,17 +68,26 @@ class UserDataClient { void setTimes(double serverSystemTime, double serverUserTime, double clientSystemTime, double clientUserTime); - int sendDataIfReady(); + int sendData(std::string access_token, std::string test_name); - private: +private: std::unique_ptr stub_; - std::string access_token_; - double QPS_; - double percentileLatency50_; - double percentileLatency90_; - double percentileLatency95_; - double percentileLatency99_; - double percentileLatency99Point9_; - bool qpsSet = false; - bool latenciesSet = false; -}; \ No newline at end of file + ClientConfig clientConfig_; + ServerConfig serverConfig_; + double QPS_ = DBL_MIN; + double QPSPerCore_ = DBL_MIN; + double percentileLatency50_ = DBL_MIN; + double percentileLatency90_ = DBL_MIN; + double percentileLatency95_ = DBL_MIN; + double percentileLatency99_ = DBL_MIN; + double percentileLatency99Point9_ = DBL_MIN; + double serverSystemTime_ = DBL_MIN; + double serverUserTime_ = DBL_MIN; + double clientSystemTime_ = DBL_MIN; + double clientUserTime_ = DBL_MIN; +}; + +} //namespace testing +} //namespace grpc + + diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index b68822436db..6b573abb50b 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -39,6 +39,8 @@ DEFINE_bool(enable_log_reporter, true, DEFINE_string(access_token, "", "Authorizing JSON string for leaderboard"); +DEFINE_string(test_name, "", "Name of the test being executed"); + // In some distros, gflags is in the namespace google, and in some others, // in gflags. This hack is enabling us to find both. namespace google {} @@ -61,7 +63,7 @@ static std::shared_ptr InitBenchmarkReporters() { } if(!FLAGS_access_token.empty()) composite_reporter->add( - std::unique_ptr(new UserDatabaseReporter("UserDataReporter", FLAGS_access_token))); + std::unique_ptr(new UserDatabaseReporter("UserDataReporter", FLAGS_access_token, FLAGS_test_name))); return std::shared_ptr(composite_reporter); } From ef3ca1b3bf0f3f8f05bfc47f84ace7be0d0052ee Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 8 Jun 2015 14:55:24 -0700 Subject: [PATCH 003/124] stable --- test/cpp/qps/report.cc | 13 ++++++------- test/cpp/qps/report.h | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 75e0e3ebd8d..5642ec8d2d5 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -124,7 +124,7 @@ UserDataClient userDataClient(grpc::CreateChannel("localhost:50052", grpc::Insec //Leaderboard Reported implementation. void UserDatabaseReporter::ReportQPS(const ScenarioResult& result) const { - double qps = result.latencies.Count() / + auto qps = result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); @@ -132,13 +132,12 @@ void UserDatabaseReporter::ReportQPS(const ScenarioResult& result) const { userDataClient.setConfigs(result.client_config, result.server_config); } -void UserDatabaseReporter::ReportQPSPerCore(const ScenarioResult& result, - const ServerConfig& server_config) const { - double qps = result.latencies.Count() / - average(result.client_resources, - [](ResourceUsage u) { return u.wall_time; }); +void UserDatabaseReporter::ReportQPSPerCore(const ScenarioResult& result) const { + auto qps = result.latencies.Count() / + average(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); - double qpsPerCore = qps / server_config.threads(); + auto qpsPerCore = qps / result.server_config.threads(); userDataClient.setQPSPerCore(qpsPerCore); userDataClient.setConfigs(result.client_config, result.server_config); diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 48da77039aa..ea09c385853 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -114,8 +114,7 @@ class UserDatabaseReporter : public Reporter { std::string access_token_; std::string test_name_; void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; - void ReportQPSPerCore(const ScenarioResult& result, - const ServerConfig& config) const GRPC_OVERRIDE; + void ReportQPSPerCore(const ScenarioResult& result) const GRPC_OVERRIDE; void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; void Flush() const; From 0acc25ad15163008015e1ef6e8848ad312c6dc08 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 8 Jun 2015 15:53:55 -0700 Subject: [PATCH 004/124] removed shell script --- test/cpp/qps/run_authenticated_test.sh | 87 -------------------------- 1 file changed, 87 deletions(-) delete mode 100755 test/cpp/qps/run_authenticated_test.sh diff --git a/test/cpp/qps/run_authenticated_test.sh b/test/cpp/qps/run_authenticated_test.sh deleted file mode 100755 index 3cde6494142..00000000000 --- a/test/cpp/qps/run_authenticated_test.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -CLIENT_ID='1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' -CLIENT_SECRET='_HGHXg4DAA59r4w4x8p6ARzD' -GRANT_TYPE='http://oauth.net/grant_type/device/1.0' -ACCESS_TOKENS_DIR='/tmp/auth_lead_access_tokens' -AUTH_TOKEN_LINK='https://www.googleapis.com/oauth2/v3/token' -GOOGLE_ACCOUNTS_LINK='https://accounts.google.com/o/oauth2/device/code' -USER_INFO_LINK='https://www.googleapis.com/oauth2/v1/userinfo' -#Performs first time authentication -#Or re-authentication if refresh token expires -RE_AUTHENTICATE() { - INIT_AUTH_JSON=$(curl -s -d "client_id=$CLIENT_ID&scope=email profile" $GOOGLE_ACCOUNTS_LINK) - - USER_CODE=$(echo $INIT_AUTH_JSON | jq .user_code | sed -e 's/^"//' -e 's/"$//') - echo 'Please use the following user code in the browser:' $USER_CODE - echo - - VERIFICATION_URL=$(echo $INIT_AUTH_JSON | jq '.verification_url' | sed -e 's/^"//' -e 's/"$//') - echo 'Verification URL:' $VERIFICATION_URL - echo - - xdg-open $VERIFICATION_URL - - DEVICE_CODE=$(echo $INIT_AUTH_JSON | jq '.device_code' | sed -e 's/^"//' -e 's/"$//') - INTERVAL=$(echo $INIT_AUTH_JSON | jq '.interval' | sed -e 's/^"//' -e 's/"$//') - - AUTH_JSON=$(curl -s -d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&code=$DEVICE_CODE&grant_type=$GRANT_TYPE" $AUTH_TOKEN_LINK) - ACCESS_TOKEN=$(echo $AUTH_JSON | jq '.access_token' | sed -e 's/^"//' -e 's/"$//') - - while [ $ACCESS_TOKEN == 'null' ] - do - sleep $INTERVAL - AUTH_JSON=$(curl -s -d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&code=$DEVICE_CODE&grant_type=$GRANT_TYPE" $AUTH_TOKEN_LINK) - ACCESS_TOKEN=$(echo $AUTH_JSON | jq '.access_token' | sed -e 's/^"//' -e 's/"$//') - done - - USER_DETAILS=$(curl -s $USER_INFO_LINK?access_token=$ACCESS_TOKEN) - USER_ID=$(echo $USER_DETAILS | jq '.email' | sed -e 's/^"//' -e 's/"$//' | awk -F"@" '{print $1}' | sed -e 's/\.//g' | awk '{print tolower($0)}') - echo $AUTH_JSON > $ACCESS_TOKENS_DIR/$USER_ID -} - -#Use existing access token -USE_ACCESS_TOKEN() { - ACCESS_TOKEN=$(jq '.access_token' $ACCESS_TOKENS_DIR/$USER_ID | sed -e 's/^"//' -e 's/"$//') - - USER_DETAILS=$(curl -s $USER_INFO_LINK?access_token=$ACCESS_TOKEN) - - ID=$(echo $USER_DETAILS | jq '.id' | sed -e 's/^"//' -e 's/"$//') - - if [ $ID == 'null' ]; then - REFRESH_ACCESS_TOKEN - fi -} - -#Obtain new access token using refresh token -REFRESH_ACCESS_TOKEN() { - REFRESH_TOKEN=$(jq '.refresh_token' $ACCESS_TOKENS_DIR/$USER_ID | sed -e 's/^"//' -e 's/"$//') - if [ $REFRESH_TOKEN == 'null' ]; then - RE_AUTHENTICATE - else - REFRESH_JSON=$(curl -s -d "refresh_token=$REFRESH_TOKEN&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=refresh_token" $AUTH_TOKEN_LINK) - - ACCESS_TOKEN=$(echo $REFRESH_JSON | jq '.access_token') - if [ $ACCESS_TOKEN == 'null' ]; then - RE_AUTHENTICATE - else - NEW_AUTH_JSON=$(jq ".access_token=$ACCESS_TOKEN" $ACCESS_TOKENS_DIR/$USER_ID) - echo $NEW_AUTH_JSON > $ACCESS_TOKENS_DIR/$USER_ID - fi - fi -} - -#create directory to store tokens, if not already present -[ ! -d $ACCESS_TOKENS_DIR ] && mkdir $ACCESS_TOKENS_DIR - -#Convert user entered email id to unique string by converting to splitting on '@' symbol, if present, -#removing '.'s and converting to lowercase -USER_ID=$(echo $2 | awk -F"@" '{print $1}' | sed -e 's/\.//g' | awk '{print tolower($0)}') - -if [ -s $ACCESS_TOKENS_DIR/$USER_ID ]; then - USE_ACCESS_TOKEN -else - RE_AUTHENTICATE -fi - -./$1 --access_token=$ACCESS_TOKEN \ No newline at end of file From f4dafb5654c8cf49a20fe4ec666d3f838dc90fef Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Wed, 10 Jun 2015 15:10:35 -0700 Subject: [PATCH 005/124] updated configs sending --- test/cpp/qps/data_script.sh | 7 +++++++ test/cpp/qps/report.cc | 4 ++-- test/cpp/qps/report.h | 9 +++++---- test/cpp/qps/run_auth_test.py | 6 +++++- test/cpp/qps/user_data.proto | 14 ++++++++------ test/cpp/qps/user_data_client.cc | 20 +++++--------------- test/cpp/qps/user_data_client.h | 2 +- test/cpp/util/benchmark_config.cc | 4 +++- 8 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 test/cpp/qps/data_script.sh mode change 100644 => 100755 test/cpp/qps/run_auth_test.py diff --git a/test/cpp/qps/data_script.sh b/test/cpp/qps/data_script.sh new file mode 100644 index 00000000000..51d840f8d80 --- /dev/null +++ b/test/cpp/qps/data_script.sh @@ -0,0 +1,7 @@ +while [ true ] +do + python run_auth_test.py ../../../bins/opt/async_streaming_ping_pong_test sidrakesh@google.com + python run_auth_test.py ../../../bins/opt/async_unary_ping_pong_test sidrakesh@google.com + python run_auth_test.py ../../../bins/opt/sync_streaming_ping_pong_test sidrakesh@google.com + python run_auth_test.py ../../../bins/opt/sync_unary_ping_pong_test sidrakesh@google.com +done \ No newline at end of file diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 5642ec8d2d5..83860ab9cee 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -175,8 +175,8 @@ void UserDatabaseReporter::ReportTimes(const ScenarioResult& result) const { userDataClient.setConfigs(result.client_config, result.server_config); } -void UserDatabaseReporter::Flush() const { - int userDataState = userDataClient.sendData(access_token_, test_name_); +void UserDatabaseReporter::SendData() const { + int userDataState = userDataClient.sendData(access_token_, test_name_, sys_info_); switch(userDataState) { case 1: diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index ea09c385853..432ed5ddf2b 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -106,18 +106,19 @@ class GprLogReporter : public Reporter { /** Reporter for client leaderboard. */ class UserDatabaseReporter : public Reporter { public: - UserDatabaseReporter(const string& name, const string& access_token, - const string& test_name) : Reporter(name), access_token_(access_token), test_name_(test_name) {} - ~UserDatabaseReporter() { Flush(); }; + UserDatabaseReporter(const string& name, const string& access_token, const string& test_name, const string& sys_info) + : Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info) {} + ~UserDatabaseReporter() { SendData(); }; private: std::string access_token_; std::string test_name_; + std::string sys_info_; void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; void ReportQPSPerCore(const ScenarioResult& result) const GRPC_OVERRIDE; void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; - void Flush() const; + void SendData() const; }; } // namespace testing diff --git a/test/cpp/qps/run_auth_test.py b/test/cpp/qps/run_auth_test.py old mode 100644 new mode 100755 index 3ed2a7c9804..75bdab22a4a --- a/test/cpp/qps/run_auth_test.py +++ b/test/cpp/qps/run_auth_test.py @@ -129,7 +129,11 @@ def main(): accessToken = reauthenticate() testName = sys.argv[1].split('/')[-1] - subprocess.call([sys.argv[1], '--access_token='+accessToken, '--test_name='+testName]) + sysInfo = os.popen('lscpu').readlines() + try: + subprocess.call([sys.argv[1], '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]')]) + except OSError: + print 'Could not execute the test, please check test path' if __name__ == "__main__": main() \ No newline at end of file diff --git a/test/cpp/qps/user_data.proto b/test/cpp/qps/user_data.proto index 27d0049cf07..947ccce60b6 100644 --- a/test/cpp/qps/user_data.proto +++ b/test/cpp/qps/user_data.proto @@ -61,9 +61,10 @@ message Metrics { message DataDetails { optional string timestamp = 1; optional string test_name = 2; - optional Metrics metrics = 3; - optional ClientConfig client_config = 4; - optional ServerConfig server_config = 5; + optional string sys_info = 3; + optional Metrics metrics = 4; + optional ClientConfig client_config = 5; + optional ServerConfig server_config = 6; } //User details @@ -91,9 +92,10 @@ message SingleUserDetails { message SingleUserRecordRequest { optional string access_token = 1; optional string test_name = 2; - optional Metrics metrics = 3; - optional ClientConfig client_config = 4; - optional ServerConfig server_config = 5; + optional string sys_info = 3; + optional Metrics metrics = 4; + optional ClientConfig client_config = 5; + optional ServerConfig server_config = 6; } //Reply to request for storing single user's data diff --git a/test/cpp/qps/user_data_client.cc b/test/cpp/qps/user_data_client.cc index 50b74276d2e..f56b79ee4a6 100644 --- a/test/cpp/qps/user_data_client.cc +++ b/test/cpp/qps/user_data_client.cc @@ -66,11 +66,13 @@ void UserDataClient::setTimes(double serverSystemTime, double serverUserTime, clientUserTime_ = clientUserTime; } -int UserDataClient::sendData(std::string access_token, std::string test_name) { +int UserDataClient::sendData(std::string access_token, std::string test_name, std::string sys_info) { SingleUserRecordRequest singleUserRecordRequest; singleUserRecordRequest.set_access_token(access_token); singleUserRecordRequest.set_test_name(test_name); + singleUserRecordRequest.set_sys_info(sys_info); + *(singleUserRecordRequest.mutable_client_config()) = clientConfig_; *(singleUserRecordRequest.mutable_server_config()) = serverConfig_; @@ -98,17 +100,5 @@ int UserDataClient::sendData(std::string access_token, std::string test_name) { return -1; } } - -// Get current date/time, format is YYYY-MM-DD.HH:mm:ss -const std::string currentDateTime() { - time_t now = time(0); - struct tm tstruct; - char buf[80]; - tstruct = *localtime(&now); - - strftime(buf, sizeof(buf), "%Y/%m/%d, %X", &tstruct); - return buf; -} - -} -} \ No newline at end of file +} //testing +} //grpc \ No newline at end of file diff --git a/test/cpp/qps/user_data_client.h b/test/cpp/qps/user_data_client.h index 0186ec90712..c99b7e9b3a3 100644 --- a/test/cpp/qps/user_data_client.h +++ b/test/cpp/qps/user_data_client.h @@ -68,7 +68,7 @@ public: void setTimes(double serverSystemTime, double serverUserTime, double clientSystemTime, double clientUserTime); - int sendData(std::string access_token, std::string test_name); + int sendData(std::string access_token, std::string test_name, std::string sys_info); private: std::unique_ptr stub_; diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 6b573abb50b..82663b6a013 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -41,6 +41,8 @@ DEFINE_string(access_token, "", "Authorizing JSON string for leaderboard"); DEFINE_string(test_name, "", "Name of the test being executed"); +DEFINE_string(sys_info, "", "System information"); + // In some distros, gflags is in the namespace google, and in some others, // in gflags. This hack is enabling us to find both. namespace google {} @@ -63,7 +65,7 @@ static std::shared_ptr InitBenchmarkReporters() { } if(!FLAGS_access_token.empty()) composite_reporter->add( - std::unique_ptr(new UserDatabaseReporter("UserDataReporter", FLAGS_access_token, FLAGS_test_name))); + std::unique_ptr(new UserDatabaseReporter("UserDataReporter", FLAGS_access_token, FLAGS_test_name, FLAGS_sys_info))); return std::shared_ptr(composite_reporter); } From b2b5b9a06946ca5b9cad759f7d5731b255b25e90 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Wed, 10 Jun 2015 15:12:34 -0700 Subject: [PATCH 006/124] removed data adding script --- test/cpp/qps/data_script.sh | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 test/cpp/qps/data_script.sh diff --git a/test/cpp/qps/data_script.sh b/test/cpp/qps/data_script.sh deleted file mode 100644 index 51d840f8d80..00000000000 --- a/test/cpp/qps/data_script.sh +++ /dev/null @@ -1,7 +0,0 @@ -while [ true ] -do - python run_auth_test.py ../../../bins/opt/async_streaming_ping_pong_test sidrakesh@google.com - python run_auth_test.py ../../../bins/opt/async_unary_ping_pong_test sidrakesh@google.com - python run_auth_test.py ../../../bins/opt/sync_streaming_ping_pong_test sidrakesh@google.com - python run_auth_test.py ../../../bins/opt/sync_unary_ping_pong_test sidrakesh@google.com -done \ No newline at end of file From 7b55362e0fcb55f42240c1164678709e50504b60 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Thu, 11 Jun 2015 20:59:14 -0700 Subject: [PATCH 007/124] updated auth script --- test/cpp/qps/run_auth_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/cpp/qps/run_auth_test.py b/test/cpp/qps/run_auth_test.py index 75bdab22a4a..06b064cad0c 100755 --- a/test/cpp/qps/run_auth_test.py +++ b/test/cpp/qps/run_auth_test.py @@ -115,7 +115,11 @@ def main(): if not os.path.exists(ACCESS_TOKENS_DIR): os.makedirs(ACCESS_TOKENS_DIR) - email = sys.argv[2] + if len(sys.argv) > 2: + email = sys.argv[2] + else: + email = raw_input('Enter your e-mail id: ') + email = email.split('@')[0].lower() userId = re.sub('[.]', '', email) From d0010ae439406e4118a1ca1788276d2c1f6fe9e5 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 15 Jun 2015 17:02:51 -0700 Subject: [PATCH 008/124] added comments --- test/cpp/qps/data_script.sh | 7 ++ test/cpp/qps/report.cc | 2 + test/cpp/qps/run_auth_test.py | 138 ++++++++++++++++++++++++++----- test/cpp/qps/user_data_client.cc | 16 +++- test/cpp/qps/user_data_client.h | 7 ++ 5 files changed, 146 insertions(+), 24 deletions(-) create mode 100644 test/cpp/qps/data_script.sh diff --git a/test/cpp/qps/data_script.sh b/test/cpp/qps/data_script.sh new file mode 100644 index 00000000000..51d840f8d80 --- /dev/null +++ b/test/cpp/qps/data_script.sh @@ -0,0 +1,7 @@ +while [ true ] +do + python run_auth_test.py ../../../bins/opt/async_streaming_ping_pong_test sidrakesh@google.com + python run_auth_test.py ../../../bins/opt/async_unary_ping_pong_test sidrakesh@google.com + python run_auth_test.py ../../../bins/opt/sync_streaming_ping_pong_test sidrakesh@google.com + python run_auth_test.py ../../../bins/opt/sync_unary_ping_pong_test sidrakesh@google.com +done \ No newline at end of file diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 83860ab9cee..91fe9524cb4 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -176,8 +176,10 @@ void UserDatabaseReporter::ReportTimes(const ScenarioResult& result) const { } void UserDatabaseReporter::SendData() const { + //send data to performance database int userDataState = userDataClient.sendData(access_token_, test_name_, sys_info_); + //check state of data sending switch(userDataState) { case 1: gpr_log(GPR_INFO, "Data sent to user database successfully"); diff --git a/test/cpp/qps/run_auth_test.py b/test/cpp/qps/run_auth_test.py index 06b064cad0c..c327a505b6f 100755 --- a/test/cpp/qps/run_auth_test.py +++ b/test/cpp/qps/run_auth_test.py @@ -1,3 +1,33 @@ +# +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# #!/usr/bin/python import os @@ -8,6 +38,7 @@ import urllib import json import time import subprocess +import fnmatch CLIENT_ID = '1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' CLIENT_SECRET = '_HGHXg4DAA59r4w4x8p6ARzD' @@ -17,6 +48,7 @@ AUTH_TOKEN_LINK = 'https://www.googleapis.com/oauth2/v3/token' GOOGLE_ACCOUNTS_LINK = 'https://accounts.google.com/o/oauth2/device/code' USER_INFO_LINK = 'https://www.googleapis.com/oauth2/v1/userinfo' +# Fetches JSON reply object, given a url and parameters def fetchJSON(url, paramDict): if len(paramDict) == 0: req = urllib2.Request(url) @@ -33,6 +65,7 @@ def fetchJSON(url, paramDict): return result +# Fetch user info; used to check if access token is valid def getUserInfo(accessToken): url = USER_INFO_LINK + '?access_token=' + accessToken paramDict = {} @@ -41,6 +74,7 @@ def getUserInfo(accessToken): return data +# Returns true if stored access token is valid def isAccessTokenValid(accessToken): data = getUserInfo(accessToken); @@ -49,32 +83,47 @@ def isAccessTokenValid(accessToken): else: return False +# Returns user id given a working access token def getUserId(accessToken): data = getUserInfo(accessToken) email = data['email'] - email = email.split('@')[0].lower() - userId = re.sub('[.]', '', email) + userId = getUserIdFromEmail(email) return userId +# Extracts a unique user id from an email address +def getUserIdFromEmail(email): + email = email.split('@')[0].lower() # take username and convert to lower case + userId = re.sub('[.]', '', email) # remove periods + + return userId + +# Use an existing access token def useAccessToken(userTokFile): with open(userTokFile, "r") as data_file: - data = json.load(data_file) + data = json.load(data_file) # load JSON data from file accessToken = data["access_token"] + # If access token has gone stale, refresh it if not isAccessTokenValid(accessToken): return refreshAccessToken(data["refresh_token"], userTokFile) return accessToken +# refresh stale access token def refreshAccessToken(refreshToken, userTokFile): + # Parameters for request paramDict = {'refresh_token':refreshToken, 'client_id':CLIENT_ID, 'client_secret':CLIENT_SECRET, 'grant_type':'refresh_token'} + # Fetch reply to request JSONBody = fetchJSON(AUTH_TOKEN_LINK, paramDict) data = json.loads(JSONBody) + if not 'access_token' in data: + # Refresh token has gone stale, re-authentication required return reauthenticate() else: + # write fresh access token to tokens file tokenData = {} with open(userTokFile, "r") as data_file: @@ -83,61 +132,108 @@ def refreshAccessToken(refreshToken, userTokFile): with open(userTokFile, "w") as data_file: tokenData['access_token'] = data['access_token'] json.dump(tokenData, data_file) - + + # return fresh access token return data['access_token'] def reauthenticate(): + # Request parameters paramDict = {'client_id':CLIENT_ID, 'scope':'email profile'} JSONBody = fetchJSON(GOOGLE_ACCOUNTS_LINK, paramDict) data = json.loads(JSONBody) print 'User authorization required\n' - print 'Please use the following code in you browser: ', data['user_code'] - print 'Verification URL: ', data['verification_url'] + print 'Please use the following code in you browser: ', data['user_code'] # Code to be entered by user in browser + print 'Verification URL: ', data['verification_url'] # Authentication link print '\nAwaiting user authorization. May take a few more seconds after authorizing...\n' authData = {} while not 'access_token' in authData: + # Request parameters authDict = {'client_id':CLIENT_ID, 'client_secret':CLIENT_SECRET, 'code':data['device_code'], 'grant_type':GRANT_TYPE} JSONBody = fetchJSON(AUTH_TOKEN_LINK, authDict) authData = json.loads(JSONBody) + # If server pinged too quickly, will get slowdown message; need to wait for specified interval time.sleep(data['interval']) + # File to write tokens newUserTokFile = ACCESS_TOKENS_DIR + '/' + getUserId(authData['access_token']) + # Write tokens to file with open(newUserTokFile, "w") as data_file: json.dump(authData, data_file) + # return working access token return authData['access_token'] -def main(): - if not os.path.exists(ACCESS_TOKENS_DIR): - os.makedirs(ACCESS_TOKENS_DIR) - - if len(sys.argv) > 2: - email = sys.argv[2] - else: - email = raw_input('Enter your e-mail id: ') - - email = email.split('@')[0].lower() - userId = re.sub('[.]', '', email) +# Fetch a working access token given user entered email id; authntication may be required +def getAccessToken(email): + # Get unique user id from email address + userId = getUserIdFromEmail(email) + # Token file userTokFile = ACCESS_TOKENS_DIR + '/' + userId accessToken = '' if os.path.exists(userTokFile): + # File containing access token exists; unless refresh token has expired, user authentication will not be required accessToken = useAccessToken(userTokFile) else: + # User authentication required accessToken = reauthenticate() - testName = sys.argv[1].split('/')[-1] - sysInfo = os.popen('lscpu').readlines() + return accessToken + +# If user has not entered full path to test, recursively searches for given test in parent folders +def findTestPath(test): + # If user entered full path to test, return it + if(os.path.isfile(test)): + return test + + testName = test.split('/')[-1] # Extract just test name + testPath = '' + + # Search for test + for root, dirnames, filenames in os.walk('../../../'): + for fileName in fnmatch.filter(filenames, '*'+testName): + testPath = os.path.join(root, fileName) + + return testPath + +def main(): + # If tokens directory does not exist, creates it + if not os.path.exists(ACCESS_TOKENS_DIR): + os.makedirs(ACCESS_TOKENS_DIR) + + if len(sys.argv) > 1: + test = sys.argv[1] + else: + test = raw_input('Enter the test path/name: ') + + if len(sys.argv) > 2: + email = sys.argv[2] + else: + email = raw_input('Enter your e-mail id: ') + + try: + # Fetch working access token + accessToken = getAccessToken(email) + except Exception, e: + print 'Error in authentication' try: - subprocess.call([sys.argv[1], '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]')]) + testPath = findTestPath(test) # Get path to test + testName = testPath.split('/')[-1] # Get test name + + # Fetch system information + sysInfo = os.popen('lscpu').readlines() + + # Run the test + subprocess.call([testPath, '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]')]) except OSError: - print 'Could not execute the test, please check test path' + print 'Could not execute the test, please check test name' + if __name__ == "__main__": main() \ No newline at end of file diff --git a/test/cpp/qps/user_data_client.cc b/test/cpp/qps/user_data_client.cc index f56b79ee4a6..a8ced7559d7 100644 --- a/test/cpp/qps/user_data_client.cc +++ b/test/cpp/qps/user_data_client.cc @@ -36,19 +36,23 @@ namespace grpc { namespace testing { +//sets the client and server config information void UserDataClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) { clientConfig_ = clientConfig; serverConfig_ = serverConfig; } +//sets the QPS void UserDataClient::setQPS(double QPS) { QPS_ = QPS; } +//sets the QPS per core void UserDataClient::setQPSPerCore(double QPSPerCore) { QPSPerCore_ = QPSPerCore; } +//sets the 50th, 90th, 95th, 99th and 99.9th percentile latency void UserDataClient::setLatencies(double percentileLatency50, double percentileLatency90, double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) { percentileLatency50_ = percentileLatency50; @@ -58,6 +62,7 @@ void UserDataClient::setLatencies(double percentileLatency50, double percentileL percentileLatency99Point9_ = percentileLatency99Point9; } +//sets the server and client, user and system times void UserDataClient::setTimes(double serverSystemTime, double serverUserTime, double clientSystemTime, double clientUserTime) { serverSystemTime_ = serverSystemTime; @@ -66,18 +71,23 @@ void UserDataClient::setTimes(double serverSystemTime, double serverUserTime, clientUserTime_ = clientUserTime; } +//sends the data to the performancew database server int UserDataClient::sendData(std::string access_token, std::string test_name, std::string sys_info) { - + //Data record request object SingleUserRecordRequest singleUserRecordRequest; + + //setting access token, name of the test and the system information singleUserRecordRequest.set_access_token(access_token); singleUserRecordRequest.set_test_name(test_name); singleUserRecordRequest.set_sys_info(sys_info); + //setting configs *(singleUserRecordRequest.mutable_client_config()) = clientConfig_; *(singleUserRecordRequest.mutable_server_config()) = serverConfig_; Metrics* metrics = singleUserRecordRequest.mutable_metrics(); + //setting metrcs in data record request if(QPS_ != DBL_MIN) metrics->set_qps(QPS_); if(QPSPerCore_ != DBL_MIN) metrics->set_qps_per_core(QPSPerCore_); if(percentileLatency50_ != DBL_MIN) metrics->set_perc_lat_50(percentileLatency50_); @@ -95,9 +105,9 @@ int UserDataClient::sendData(std::string access_token, std::string test_name, st Status status = stub_->RecordSingleClientData(&context, singleUserRecordRequest, &singleUserRecordReply); if (status.IsOk()) { - return 1; + return 1; //data sent to database successfully } else { - return -1; + return -1; //error in data sending } } } //testing diff --git a/test/cpp/qps/user_data_client.h b/test/cpp/qps/user_data_client.h index c99b7e9b3a3..c2e07ef5cd9 100644 --- a/test/cpp/qps/user_data_client.h +++ b/test/cpp/qps/user_data_client.h @@ -49,6 +49,7 @@ namespace grpc{ namespace testing { +//Manages data sending to performance database server class UserDataClient { public: UserDataClient(std::shared_ptr channel) @@ -56,18 +57,24 @@ public: ~UserDataClient() {} + //sets the client and server config information void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig); + //sets the QPS void setQPS(double QPS); + //sets the QPS per core void setQPSPerCore(double QPSPerCore); + //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency void setLatencies(double percentileLatency50, double percentileLatency90, double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); + //sets the server and client, user and system times void setTimes(double serverSystemTime, double serverUserTime, double clientSystemTime, double clientUserTime); + //sends the data to the performancew database server int sendData(std::string access_token, std::string test_name, std::string sys_info); private: From 08e8bab4b81f8c2970b17ef8377e30d766eb146b Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 15 Jun 2015 17:04:09 -0700 Subject: [PATCH 009/124] removed data script --- test/cpp/qps/data_script.sh | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 test/cpp/qps/data_script.sh diff --git a/test/cpp/qps/data_script.sh b/test/cpp/qps/data_script.sh deleted file mode 100644 index 51d840f8d80..00000000000 --- a/test/cpp/qps/data_script.sh +++ /dev/null @@ -1,7 +0,0 @@ -while [ true ] -do - python run_auth_test.py ../../../bins/opt/async_streaming_ping_pong_test sidrakesh@google.com - python run_auth_test.py ../../../bins/opt/async_unary_ping_pong_test sidrakesh@google.com - python run_auth_test.py ../../../bins/opt/sync_streaming_ping_pong_test sidrakesh@google.com - python run_auth_test.py ../../../bins/opt/sync_unary_ping_pong_test sidrakesh@google.com -done \ No newline at end of file From e2902dee317bdab3cca20501032d74ffdd1b6f55 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Wed, 17 Jun 2015 15:01:43 -0700 Subject: [PATCH 010/124] commented --- test/cpp/qps/report.cc | 1 + test/cpp/qps/run_auth_test.py | 47 ++++++++++++++++++++++++++----- test/cpp/util/benchmark_config.cc | 5 +++- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 91fe9524cb4..25cc13156a9 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -139,6 +139,7 @@ void UserDatabaseReporter::ReportQPSPerCore(const ScenarioResult& result) const auto qpsPerCore = qps / result.server_config.threads(); + userDataClient.setQPS(qps); userDataClient.setQPSPerCore(qpsPerCore); userDataClient.setConfigs(result.client_config, result.server_config); } diff --git a/test/cpp/qps/run_auth_test.py b/test/cpp/qps/run_auth_test.py index c327a505b6f..39a4a0ae3fc 100755 --- a/test/cpp/qps/run_auth_test.py +++ b/test/cpp/qps/run_auth_test.py @@ -59,7 +59,7 @@ def fetchJSON(url, paramDict): try: response = urllib2.urlopen(req) result = response.read() - + except urllib2.HTTPError, error: result = error.read() @@ -71,7 +71,7 @@ def getUserInfo(accessToken): paramDict = {} JSONBody = fetchJSON(url, paramDict) data = json.loads(JSONBody) - + return data # Returns true if stored access token is valid @@ -197,11 +197,44 @@ def findTestPath(test): # Search for test for root, dirnames, filenames in os.walk('../../../'): - for fileName in fnmatch.filter(filenames, '*'+testName): - testPath = os.path.join(root, fileName) + for fileName in fnmatch.filter(filenames, testName): + testPath = os.path.join(root, fileName) return testPath +def getSysInfo(): + # Fetch system information + sysInfo = os.popen('lscpu').readlines() + + NICs = os.popen('ifconfig | cut -c1-8 | sed \'/^\s*$/d\' | sort -u').readlines() + nicAddrs = os.popen('ifconfig | grep -oE "inet addr:([0-9]{1,3}\.){3}[0-9]{1,3}"').readlines() + + nicInfo = [] + + for i in range(0, len(NICs)): + NIC = NICs[i] + NIC = re.sub(r'[^\w]', '', NIC) + + ethtoolProcess = subprocess.Popen(["ethtool",NIC], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + ethtoolResult = ethtoolProcess.communicate()[0] + + ethtoolResultList = ethtoolResult.split('\n\t') + for ethtoolString in ethtoolResultList: + if ethtoolString.startswith('Speed'): + ethtoolString = ethtoolString.split(':')[1] + ethtoolString = ethtoolString.replace('Mb/s',' Mbps') + nicInfo.append(NIC + ' speed: ' + ethtoolString + '\n') + nicInfo.append(NIC + ' inet address: ' + nicAddrs[i].split(':')[1]) + + print 'Obtaining network info....' + tcp_rr_rate = str(os.popen('netperf -t TCP_RR -v 0').readlines()[1]) + print 'Network info obtained' + + nicInfo.append('TCP RR Transmission Rate per sec: ' + tcp_rr_rate + '\n') + sysInfo = sysInfo + nicInfo + + return sysInfo + def main(): # If tokens directory does not exist, creates it if not os.path.exists(ACCESS_TOKENS_DIR): @@ -227,11 +260,11 @@ def main(): testPath = findTestPath(test) # Get path to test testName = testPath.split('/')[-1] # Get test name - # Fetch system information - sysInfo = os.popen('lscpu').readlines() + sysInfo = getSysInfo() + print '\nBeginning test:\n' # Run the test - subprocess.call([testPath, '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]')]) + subprocess.call([testPath, '--report_metrics_db=true', '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]')]) except OSError: print 'Could not execute the test, please check test name' diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 82663b6a013..250bb7ac8e3 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -37,6 +37,8 @@ DEFINE_bool(enable_log_reporter, true, "Enable reporting of benchmark results through GprLog"); +DEFINE_bool(report_metrics_db, false, "True if metrics to be reported to performance database"); + DEFINE_string(access_token, "", "Authorizing JSON string for leaderboard"); DEFINE_string(test_name, "", "Name of the test being executed"); @@ -63,9 +65,10 @@ static std::shared_ptr InitBenchmarkReporters() { composite_reporter->add( std::unique_ptr(new GprLogReporter("LogReporter"))); } - if(!FLAGS_access_token.empty()) + if(FLAGS_report_metrics_db) { composite_reporter->add( std::unique_ptr(new UserDatabaseReporter("UserDataReporter", FLAGS_access_token, FLAGS_test_name, FLAGS_sys_info))); + } return std::shared_ptr(composite_reporter); } From 929191b4be8d958c927499092cb5f963b11148eb Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Thu, 18 Jun 2015 09:13:53 -0700 Subject: [PATCH 011/124] edited test script --- test/cpp/qps/{run_auth_test.py => run_perf_db_test.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/cpp/qps/{run_auth_test.py => run_perf_db_test.py} (99%) diff --git a/test/cpp/qps/run_auth_test.py b/test/cpp/qps/run_perf_db_test.py similarity index 99% rename from test/cpp/qps/run_auth_test.py rename to test/cpp/qps/run_perf_db_test.py index 39a4a0ae3fc..b2ca033e7ec 100755 --- a/test/cpp/qps/run_auth_test.py +++ b/test/cpp/qps/run_perf_db_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/python # # Copyright 2015, Google Inc. # All rights reserved. @@ -28,7 +29,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -#!/usr/bin/python import os import sys From bfa67ddbd4a5515ae92bd336390a4f6b71bcb661 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Thu, 18 Jun 2015 10:37:41 -0700 Subject: [PATCH 012/124] changed access tokens folder position --- test/cpp/qps/run_perf_db_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/cpp/qps/run_perf_db_test.py b/test/cpp/qps/run_perf_db_test.py index b2ca033e7ec..7f840fa723d 100755 --- a/test/cpp/qps/run_perf_db_test.py +++ b/test/cpp/qps/run_perf_db_test.py @@ -43,7 +43,7 @@ import fnmatch CLIENT_ID = '1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' CLIENT_SECRET = '_HGHXg4DAA59r4w4x8p6ARzD' GRANT_TYPE = 'http://oauth.net/grant_type/device/1.0' -ACCESS_TOKENS_DIR = '/tmp/auth_lead_access_tokens' +ACCESS_TOKENS_DIR = '/usr/local/auth_access_tokens' AUTH_TOKEN_LINK = 'https://www.googleapis.com/oauth2/v3/token' GOOGLE_ACCOUNTS_LINK = 'https://accounts.google.com/o/oauth2/device/code' USER_INFO_LINK = 'https://www.googleapis.com/oauth2/v1/userinfo' @@ -223,7 +223,7 @@ def getSysInfo(): if ethtoolString.startswith('Speed'): ethtoolString = ethtoolString.split(':')[1] ethtoolString = ethtoolString.replace('Mb/s',' Mbps') - nicInfo.append(NIC + ' speed: ' + ethtoolString + '\n') + nicInfo.append('NIC ' + NIC + ' speed: ' + ethtoolString + '\n') nicInfo.append(NIC + ' inet address: ' + nicAddrs[i].split(':')[1]) print 'Obtaining network info....' @@ -238,7 +238,8 @@ def getSysInfo(): def main(): # If tokens directory does not exist, creates it if not os.path.exists(ACCESS_TOKENS_DIR): - os.makedirs(ACCESS_TOKENS_DIR) + subprocess.call(['sudo', 'mkdir', ACCESS_TOKENS_DIR]) + subprocess.call(['sudo', 'chmod', '777', ACCESS_TOKENS_DIR]) if len(sys.argv) > 1: test = sys.argv[1] From e74a458813fcdf8b35080e30fc1190edcd5b88be Mon Sep 17 00:00:00 2001 From: sidrakesh93 Date: Thu, 18 Jun 2015 11:22:06 -0700 Subject: [PATCH 013/124] Update report.cc --- test/cpp/qps/report.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 25cc13156a9..c524327ff03 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -122,7 +122,7 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) const { UserDataClient userDataClient(grpc::CreateChannel("localhost:50052", grpc::InsecureCredentials(), ChannelArguments())); -//Leaderboard Reported implementation. +//Performance database reporter implementation. void UserDatabaseReporter::ReportQPS(const ScenarioResult& result) const { auto qps = result.latencies.Count() / average(result.client_resources, From cc5857b624a0f99af1cdf9944213673080d0fe52 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Thu, 18 Jun 2015 16:45:55 -0700 Subject: [PATCH 014/124] Fixed hanging client declaration, server address can be passed now --- Makefile | 46 ++++++++--------- build.json | 10 ++-- .../qps/{user_data.proto => perf_db.proto} | 2 +- ...{user_data_client.cc => perf_db_client.cc} | 20 ++++---- .../{user_data_client.h => perf_db_client.h} | 51 ++++++++++--------- test/cpp/qps/report.cc | 41 ++++++++------- test/cpp/qps/report.h | 12 +++-- test/cpp/qps/run_perf_db_test.py | 4 +- test/cpp/util/benchmark_config.cc | 4 +- 9 files changed, 99 insertions(+), 91 deletions(-) rename test/cpp/qps/{user_data.proto => perf_db.proto} (99%) rename test/cpp/qps/{user_data_client.cc => perf_db_client.cc} (86%) rename test/cpp/qps/{user_data_client.h => perf_db_client.h} (71%) diff --git a/Makefile b/Makefile index ef7795c2902..a3f6803a3c6 100644 --- a/Makefile +++ b/Makefile @@ -2502,30 +2502,30 @@ $(GENDIR)/examples/pubsub/pubsub.grpc.pb.cc: examples/pubsub/pubsub.proto $(PROT endif ifeq ($(NO_PROTOC),true) -$(GENDIR)/test/cpp/qps/qpstest.pb.cc: protoc_dep_error -$(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc: protoc_dep_error +$(GENDIR)/test/cpp/qps/perf_db.pb.cc: protoc_dep_error +$(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc: protoc_dep_error else -$(GENDIR)/test/cpp/qps/qpstest.pb.cc: test/cpp/qps/qpstest.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) +$(GENDIR)/test/cpp/qps/perf_db.pb.cc: test/cpp/qps/perf_db.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(E) "[PROTOC] Generating protobuf CC file from $<" $(Q) mkdir -p `dirname $@` $(Q) $(PROTOC) --cpp_out=$(GENDIR) $< -$(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc: test/cpp/qps/qpstest.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) +$(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc: test/cpp/qps/perf_db.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" $(Q) mkdir -p `dirname $@` $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $< endif ifeq ($(NO_PROTOC),true) -$(GENDIR)/test/cpp/qps/user_data.pb.cc: protoc_dep_error -$(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc: protoc_dep_error +$(GENDIR)/test/cpp/qps/qpstest.pb.cc: protoc_dep_error +$(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc: protoc_dep_error else -$(GENDIR)/test/cpp/qps/user_data.pb.cc: test/cpp/qps/user_data.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) +$(GENDIR)/test/cpp/qps/qpstest.pb.cc: test/cpp/qps/qpstest.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(E) "[PROTOC] Generating protobuf CC file from $<" $(Q) mkdir -p `dirname $@` $(Q) $(PROTOC) --cpp_out=$(GENDIR) $< -$(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc: test/cpp/qps/user_data.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) +$(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc: test/cpp/qps/qpstest.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" $(Q) mkdir -p `dirname $@` $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $< @@ -3532,9 +3532,9 @@ endif LIBGRPC++_BENCHMARK_CONFIG_SRC = \ $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc \ - $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc \ + $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc \ + test/cpp/qps/perf_db_client.cc \ test/cpp/qps/report.cc \ - test/cpp/qps/user_data_client.cc \ test/cpp/util/benchmark_config.cc \ @@ -3579,9 +3579,9 @@ ifneq ($(NO_DEPS),true) -include $(LIBGRPC++_BENCHMARK_CONFIG_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/user_data_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/perf_db_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc LIBGRPC++_TEST_CONFIG_SRC = \ @@ -4094,15 +4094,15 @@ $(OBJDIR)/$(CONFIG)/examples/pubsub/subscriber.o: $(GENDIR)/examples/pubsub/labe LIBQPS_SRC = \ $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc \ - $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc \ + $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc \ test/cpp/qps/client_async.cc \ test/cpp/qps/client_sync.cc \ test/cpp/qps/driver.cc \ + test/cpp/qps/perf_db_client.cc \ test/cpp/qps/qps_worker.cc \ test/cpp/qps/server_async.cc \ test/cpp/qps/server_sync.cc \ test/cpp/qps/timer.cc \ - test/cpp/qps/user_data_client.cc \ LIBQPS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBQPS_SRC)))) @@ -4146,14 +4146,14 @@ ifneq ($(NO_DEPS),true) -include $(LIBQPS_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/user_data_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/user_data.pb.cc $(GENDIR)/test/cpp/qps/user_data.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/perf_db_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc LIBGRPC_CSHARP_EXT_SRC = \ diff --git a/build.json b/build.json index 9342aea0355..3c8dd756cac 100644 --- a/build.json +++ b/build.json @@ -541,9 +541,9 @@ "language": "c++", "src": [ "test/cpp/qps/qpstest.proto", - "test/cpp/qps/user_data.proto", + "test/cpp/qps/perf_db.proto", + "test/cpp/qps/perf_db_client.cc", "test/cpp/qps/report.cc", - "test/cpp/qps/user_data_client.cc", "test/cpp/util/benchmark_config.cc" ] }, @@ -714,15 +714,15 @@ ], "src": [ "test/cpp/qps/qpstest.proto", - "test/cpp/qps/user_data.proto", + "test/cpp/qps/perf_db.proto", "test/cpp/qps/client_async.cc", "test/cpp/qps/client_sync.cc", "test/cpp/qps/driver.cc", + "test/cpp/qps/perf_db_client.cc", "test/cpp/qps/qps_worker.cc", "test/cpp/qps/server_async.cc", "test/cpp/qps/server_sync.cc", - "test/cpp/qps/timer.cc", - "test/cpp/qps/user_data_client.cc" + "test/cpp/qps/timer.cc" ], "deps": [ "grpc_test_util", diff --git a/test/cpp/qps/user_data.proto b/test/cpp/qps/perf_db.proto similarity index 99% rename from test/cpp/qps/user_data.proto rename to test/cpp/qps/perf_db.proto index 947ccce60b6..f4f174937c0 100644 --- a/test/cpp/qps/user_data.proto +++ b/test/cpp/qps/perf_db.proto @@ -33,7 +33,7 @@ import "test/cpp/qps/qpstest.proto"; package grpc.testing; -service UserDataTransfer { +service PerfDbTransfer { // Sends client info rpc RecordSingleClientData (SingleUserRecordRequest) returns (SingleUserRecordReply) {} diff --git a/test/cpp/qps/user_data_client.cc b/test/cpp/qps/perf_db_client.cc similarity index 86% rename from test/cpp/qps/user_data_client.cc rename to test/cpp/qps/perf_db_client.cc index a8ced7559d7..6a1fe7e26e7 100644 --- a/test/cpp/qps/user_data_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -31,30 +31,30 @@ * */ -#include "user_data_client.h" +#include "perf_db_client.h" namespace grpc { namespace testing { //sets the client and server config information -void UserDataClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) { +void PerfDbClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) const { clientConfig_ = clientConfig; serverConfig_ = serverConfig; } //sets the QPS -void UserDataClient::setQPS(double QPS) { +void PerfDbClient::setQPS(double QPS) const { QPS_ = QPS; } //sets the QPS per core -void UserDataClient::setQPSPerCore(double QPSPerCore) { +void PerfDbClient::setQPSPerCore(double QPSPerCore) const { QPSPerCore_ = QPSPerCore; } //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency -void UserDataClient::setLatencies(double percentileLatency50, double percentileLatency90, - double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) { +void PerfDbClient::setLatencies(double percentileLatency50, double percentileLatency90, + double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) const { percentileLatency50_ = percentileLatency50; percentileLatency90_ = percentileLatency90; percentileLatency95_ = percentileLatency95; @@ -63,8 +63,8 @@ void UserDataClient::setLatencies(double percentileLatency50, double percentileL } //sets the server and client, user and system times -void UserDataClient::setTimes(double serverSystemTime, double serverUserTime, - double clientSystemTime, double clientUserTime) { +void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, + double clientSystemTime, double clientUserTime) const { serverSystemTime_ = serverSystemTime; serverUserTime_ = serverUserTime; clientSystemTime_ = clientSystemTime; @@ -72,7 +72,7 @@ void UserDataClient::setTimes(double serverSystemTime, double serverUserTime, } //sends the data to the performancew database server -int UserDataClient::sendData(std::string access_token, std::string test_name, std::string sys_info) { +int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info) const { //Data record request object SingleUserRecordRequest singleUserRecordRequest; @@ -104,7 +104,7 @@ int UserDataClient::sendData(std::string access_token, std::string test_name, st ClientContext context; Status status = stub_->RecordSingleClientData(&context, singleUserRecordRequest, &singleUserRecordReply); - if (status.IsOk()) { + if (status.ok()) { return 1; //data sent to database successfully } else { return -1; //error in data sending diff --git a/test/cpp/qps/user_data_client.h b/test/cpp/qps/perf_db_client.h similarity index 71% rename from test/cpp/qps/user_data_client.h rename to test/cpp/qps/perf_db_client.h index c2e07ef5cd9..4a63dbf3d28 100644 --- a/test/cpp/qps/user_data_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -43,55 +43,56 @@ #include #include #include -#include "test/cpp/qps/user_data.grpc.pb.h" +#include "test/cpp/qps/perf_db.grpc.pb.h" namespace grpc{ namespace testing { //Manages data sending to performance database server -class UserDataClient { +class PerfDbClient { public: - UserDataClient(std::shared_ptr channel) - : stub_(UserDataTransfer::NewStub(channel)) {} + PerfDbClient() {} - ~UserDataClient() {} + void init(std::shared_ptr channel) { stub_ = PerfDbTransfer::NewStub(channel); } + + ~PerfDbClient() {} //sets the client and server config information - void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig); + void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) const; //sets the QPS - void setQPS(double QPS); + void setQPS(double QPS) const; //sets the QPS per core - void setQPSPerCore(double QPSPerCore); + void setQPSPerCore(double QPSPerCore) const; //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency void setLatencies(double percentileLatency50, double percentileLatency90, - double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); + double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) const; //sets the server and client, user and system times void setTimes(double serverSystemTime, double serverUserTime, - double clientSystemTime, double clientUserTime); + double clientSystemTime, double clientUserTime) const; //sends the data to the performancew database server - int sendData(std::string access_token, std::string test_name, std::string sys_info); + int sendData(std::string access_token, std::string test_name, std::string sys_info) const; private: - std::unique_ptr stub_; - ClientConfig clientConfig_; - ServerConfig serverConfig_; - double QPS_ = DBL_MIN; - double QPSPerCore_ = DBL_MIN; - double percentileLatency50_ = DBL_MIN; - double percentileLatency90_ = DBL_MIN; - double percentileLatency95_ = DBL_MIN; - double percentileLatency99_ = DBL_MIN; - double percentileLatency99Point9_ = DBL_MIN; - double serverSystemTime_ = DBL_MIN; - double serverUserTime_ = DBL_MIN; - double clientSystemTime_ = DBL_MIN; - double clientUserTime_ = DBL_MIN; + std::unique_ptr stub_; + mutable ClientConfig clientConfig_; + mutable ServerConfig serverConfig_; + mutable double QPS_ = DBL_MIN; + mutable double QPSPerCore_ = DBL_MIN; + mutable double percentileLatency50_ = DBL_MIN; + mutable double percentileLatency90_ = DBL_MIN; + mutable double percentileLatency95_ = DBL_MIN; + mutable double percentileLatency99_ = DBL_MIN; + mutable double percentileLatency99Point9_ = DBL_MIN; + mutable double serverSystemTime_ = DBL_MIN; + mutable double serverUserTime_ = DBL_MIN; + mutable double clientSystemTime_ = DBL_MIN; + mutable double clientUserTime_ = DBL_MIN; }; } //namespace testing diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index c524327ff03..3d71f76fd22 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -35,7 +35,6 @@ #include #include "test/cpp/qps/stats.h" -#include "user_data_client.h" namespace grpc { namespace testing { @@ -119,41 +118,41 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) const { [](ResourceUsage u) { return u.wall_time; })); } -UserDataClient userDataClient(grpc::CreateChannel("localhost:50052", grpc::InsecureCredentials(), - ChannelArguments())); +// perfDbClient perfDbClient(grpc::CreateChannel("localhost:50052", grpc::InsecureCredentials(), +// ChannelArguments())); //Performance database reporter implementation. -void UserDatabaseReporter::ReportQPS(const ScenarioResult& result) const { +void PerfDbReporter::ReportQPS(const ScenarioResult& result) const { auto qps = result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - userDataClient.setQPS(qps); - userDataClient.setConfigs(result.client_config, result.server_config); + perfDbClient.setQPS(qps); + perfDbClient.setConfigs(result.client_config, result.server_config); } -void UserDatabaseReporter::ReportQPSPerCore(const ScenarioResult& result) const { +void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) const { auto qps = result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); auto qpsPerCore = qps / result.server_config.threads(); - userDataClient.setQPS(qps); - userDataClient.setQPSPerCore(qpsPerCore); - userDataClient.setConfigs(result.client_config, result.server_config); + perfDbClient.setQPS(qps); + perfDbClient.setQPSPerCore(qpsPerCore); + perfDbClient.setConfigs(result.client_config, result.server_config); } -void UserDatabaseReporter::ReportLatency(const ScenarioResult& result) const { - userDataClient.setLatencies(result.latencies.Percentile(50) / 1000, +void PerfDbReporter::ReportLatency(const ScenarioResult& result) const { + perfDbClient.setLatencies(result.latencies.Percentile(50) / 1000, result.latencies.Percentile(90) / 1000, result.latencies.Percentile(95) / 1000, result.latencies.Percentile(99) / 1000, result.latencies.Percentile(99.9) / 1000); - userDataClient.setConfigs(result.client_config, result.server_config); + perfDbClient.setConfigs(result.client_config, result.server_config); } -void UserDatabaseReporter::ReportTimes(const ScenarioResult& result) const { +void PerfDbReporter::ReportTimes(const ScenarioResult& result) const { double serverSystemTime = 100.0 * sum(result.server_resources, [](ResourceUsage u) { return u.system_time; }) / sum(result.server_resources, @@ -171,22 +170,22 @@ void UserDatabaseReporter::ReportTimes(const ScenarioResult& result) const { sum(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - userDataClient.setTimes(serverSystemTime, serverUserTime, + perfDbClient.setTimes(serverSystemTime, serverUserTime, clientSystemTime, clientUserTime); - userDataClient.setConfigs(result.client_config, result.server_config); + perfDbClient.setConfigs(result.client_config, result.server_config); } -void UserDatabaseReporter::SendData() const { +void PerfDbReporter::SendData() const { //send data to performance database - int userDataState = userDataClient.sendData(access_token_, test_name_, sys_info_); + int dataState = perfDbClient.sendData(access_token_, test_name_, sys_info_); //check state of data sending - switch(userDataState) { + switch(dataState) { case 1: - gpr_log(GPR_INFO, "Data sent to user database successfully"); + gpr_log(GPR_INFO, "Data sent to performance database successfully"); break; case -1: - gpr_log(GPR_INFO, "Data could not be sent to user database"); + gpr_log(GPR_INFO, "Data could not be sent to performance database"); break; } } diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 432ed5ddf2b..afc79ff75fc 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -41,6 +41,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/qpstest.grpc.pb.h" +#include "perf_db_client.h" namespace grpc { namespace testing { @@ -104,13 +105,16 @@ class GprLogReporter : public Reporter { }; /** Reporter for client leaderboard. */ -class UserDatabaseReporter : public Reporter { +class PerfDbReporter : public Reporter { public: - UserDatabaseReporter(const string& name, const string& access_token, const string& test_name, const string& sys_info) - : Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info) {} - ~UserDatabaseReporter() { SendData(); }; + PerfDbReporter(const string& name, const string& access_token, const string& test_name, const string& sys_info, const string& server_address) + : Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info) { + perfDbClient.init(grpc::CreateChannel(server_address, grpc::InsecureCredentials(), ChannelArguments())); + } + ~PerfDbReporter() { SendData(); }; private: + PerfDbClient perfDbClient; std::string access_token_; std::string test_name_; std::string sys_info_; diff --git a/test/cpp/qps/run_perf_db_test.py b/test/cpp/qps/run_perf_db_test.py index 7f840fa723d..34007aa97c9 100755 --- a/test/cpp/qps/run_perf_db_test.py +++ b/test/cpp/qps/run_perf_db_test.py @@ -257,6 +257,8 @@ def main(): except Exception, e: print 'Error in authentication' + serverAddress = 'sidrakesh.mtv.google.corp.com:50052' + try: testPath = findTestPath(test) # Get path to test testName = testPath.split('/')[-1] # Get test name @@ -265,7 +267,7 @@ def main(): print '\nBeginning test:\n' # Run the test - subprocess.call([testPath, '--report_metrics_db=true', '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]')]) + subprocess.call([testPath, '--report_metrics_db=true', '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]'), '--server_address='+serverAddress]) except OSError: print 'Could not execute the test, please check test name' diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 250bb7ac8e3..f8cfabd0d68 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -45,6 +45,8 @@ DEFINE_string(test_name, "", "Name of the test being executed"); DEFINE_string(sys_info, "", "System information"); +DEFINE_string(server_address, "localhost:50052", "Address of the performance database server"); + // In some distros, gflags is in the namespace google, and in some others, // in gflags. This hack is enabling us to find both. namespace google {} @@ -67,7 +69,7 @@ static std::shared_ptr InitBenchmarkReporters() { } if(FLAGS_report_metrics_db) { composite_reporter->add( - std::unique_ptr(new UserDatabaseReporter("UserDataReporter", FLAGS_access_token, FLAGS_test_name, FLAGS_sys_info))); + std::unique_ptr(new PerfDbReporter("PerfDbReporter", FLAGS_access_token, FLAGS_test_name, FLAGS_sys_info, FLAGS_server_address))); } return std::shared_ptr(composite_reporter); From 12c65b1a7e3d6707b703d6294144c63c9dac122d Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Fri, 19 Jun 2015 11:16:12 -0700 Subject: [PATCH 015/124] slightly updated tool script --- test/cpp/qps/run_perf_db_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/cpp/qps/run_perf_db_test.py b/test/cpp/qps/run_perf_db_test.py index 34007aa97c9..634555546a3 100755 --- a/test/cpp/qps/run_perf_db_test.py +++ b/test/cpp/qps/run_perf_db_test.py @@ -230,7 +230,7 @@ def getSysInfo(): tcp_rr_rate = str(os.popen('netperf -t TCP_RR -v 0').readlines()[1]) print 'Network info obtained' - nicInfo.append('TCP RR Transmission Rate per sec: ' + tcp_rr_rate + '\n') + nicInfo.append('TCP RR transmission rate per sec: ' + tcp_rr_rate + '\n') sysInfo = sysInfo + nicInfo return sysInfo @@ -257,13 +257,14 @@ def main(): except Exception, e: print 'Error in authentication' + # Address of the performance database server serverAddress = 'sidrakesh.mtv.google.corp.com:50052' try: testPath = findTestPath(test) # Get path to test testName = testPath.split('/')[-1] # Get test name - sysInfo = getSysInfo() + sysInfo = getSysInfo() # get the system information print '\nBeginning test:\n' # Run the test From 31014d26aa2757de26e9f395bab84220a593070e Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Fri, 19 Jun 2015 15:24:19 -0700 Subject: [PATCH 016/124] flags handled using python_gflags --- test/cpp/qps/run_perf_db_test.py | 73 ++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/test/cpp/qps/run_perf_db_test.py b/test/cpp/qps/run_perf_db_test.py index 634555546a3..fd0d397a66f 100755 --- a/test/cpp/qps/run_perf_db_test.py +++ b/test/cpp/qps/run_perf_db_test.py @@ -39,15 +39,23 @@ import json import time import subprocess import fnmatch +import gflags CLIENT_ID = '1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' CLIENT_SECRET = '_HGHXg4DAA59r4w4x8p6ARzD' GRANT_TYPE = 'http://oauth.net/grant_type/device/1.0' -ACCESS_TOKENS_DIR = '/usr/local/auth_access_tokens' +DEFAULT_ACCESS_TOKENS_DIR = '/usr/local/auth_access_tokens' AUTH_TOKEN_LINK = 'https://www.googleapis.com/oauth2/v3/token' GOOGLE_ACCOUNTS_LINK = 'https://accounts.google.com/o/oauth2/device/code' USER_INFO_LINK = 'https://www.googleapis.com/oauth2/v1/userinfo' +FLAGS = gflags.FLAGS + +gflags.DEFINE_string('test', None, 'Name of the test') +gflags.DEFINE_string('email', None, 'gmail id') +gflags.DEFINE_string('server_address', 'localhost:50052', 'Address of the performance database server') +gflags.DEFINE_string('tokens_dir', DEFAULT_ACCESS_TOKENS_DIR, 'Location of the access tokens') + # Fetches JSON reply object, given a url and parameters def fetchJSON(url, paramDict): if len(paramDict) == 0: @@ -136,7 +144,7 @@ def refreshAccessToken(refreshToken, userTokFile): # return fresh access token return data['access_token'] -def reauthenticate(): +def reauthenticate(tokensDir): # Request parameters paramDict = {'client_id':CLIENT_ID, 'scope':'email profile'} JSONBody = fetchJSON(GOOGLE_ACCOUNTS_LINK, paramDict) @@ -158,7 +166,7 @@ def reauthenticate(): time.sleep(data['interval']) # File to write tokens - newUserTokFile = ACCESS_TOKENS_DIR + '/' + getUserId(authData['access_token']) + newUserTokFile = tokensDir + '/' + getUserId(authData['access_token']) # Write tokens to file with open(newUserTokFile, "w") as data_file: @@ -168,12 +176,12 @@ def reauthenticate(): return authData['access_token'] # Fetch a working access token given user entered email id; authntication may be required -def getAccessToken(email): +def getAccessToken(email, tokensDir): # Get unique user id from email address userId = getUserIdFromEmail(email) # Token file - userTokFile = ACCESS_TOKENS_DIR + '/' + userId + userTokFile = tokensDir + '/' + userId accessToken = '' @@ -182,7 +190,7 @@ def getAccessToken(email): accessToken = useAccessToken(userTokFile) else: # User authentication required - accessToken = reauthenticate() + accessToken = reauthenticate(tokensDir) return accessToken @@ -235,42 +243,51 @@ def getSysInfo(): return sysInfo -def main(): - # If tokens directory does not exist, creates it - if not os.path.exists(ACCESS_TOKENS_DIR): - subprocess.call(['sudo', 'mkdir', ACCESS_TOKENS_DIR]) - subprocess.call(['sudo', 'chmod', '777', ACCESS_TOKENS_DIR]) +def main(argv): + try: + argv = FLAGS(argv) + except Exception, e: + print '%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS) + sys.exit(1) - if len(sys.argv) > 1: - test = sys.argv[1] - else: - test = raw_input('Enter the test path/name: ') + tokensDir = FLAGS.tokens_dir - if len(sys.argv) > 2: - email = sys.argv[2] - else: - email = raw_input('Enter your e-mail id: ') + # If tokens directory does not exist, creates it + if not os.path.exists(tokensDir): + os.makedirs(tokensDir) try: # Fetch working access token - accessToken = getAccessToken(email) - except Exception, e: - print 'Error in authentication' + accessToken = getAccessToken(FLAGS.email, tokensDir) + except AttributeError: + print '\nError: Please provide email address as an argument\n' + sys.exit(1) + except: + print '\nError in authentication\n' + sys.exit(1) # Address of the performance database server - serverAddress = 'sidrakesh.mtv.google.corp.com:50052' + serverAddress = FLAGS.server_address + # Get path to test try: - testPath = findTestPath(test) # Get path to test - testName = testPath.split('/')[-1] # Get test name + testPath = findTestPath(FLAGS.test) + except TypeError: + print '\nError: Please provide test name/path as argument\n' + sys.exit(1) - sysInfo = getSysInfo() # get the system information + # Get name of the test + testName = testPath.split('/')[-1] + # Get the system information + sysInfo = getSysInfo() + + try: print '\nBeginning test:\n' # Run the test subprocess.call([testPath, '--report_metrics_db=true', '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]'), '--server_address='+serverAddress]) except OSError: - print 'Could not execute the test, please check test name' + print 'Could not execute the test' if __name__ == "__main__": - main() \ No newline at end of file + main(sys.argv) \ No newline at end of file From 64967d4faccda02b2cd2cfb6c7a7fedab1930ebf Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Fri, 19 Jun 2015 16:58:26 -0700 Subject: [PATCH 017/124] removed dependency on python_gflags, using argparse instead --- test/cpp/qps/run_perf_db_test.py | 42 +++++++++++++++----------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/test/cpp/qps/run_perf_db_test.py b/test/cpp/qps/run_perf_db_test.py index fd0d397a66f..a8e69ea1f02 100755 --- a/test/cpp/qps/run_perf_db_test.py +++ b/test/cpp/qps/run_perf_db_test.py @@ -39,22 +39,20 @@ import json import time import subprocess import fnmatch -import gflags +import argparse CLIENT_ID = '1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' CLIENT_SECRET = '_HGHXg4DAA59r4w4x8p6ARzD' GRANT_TYPE = 'http://oauth.net/grant_type/device/1.0' -DEFAULT_ACCESS_TOKENS_DIR = '/usr/local/auth_access_tokens' AUTH_TOKEN_LINK = 'https://www.googleapis.com/oauth2/v3/token' GOOGLE_ACCOUNTS_LINK = 'https://accounts.google.com/o/oauth2/device/code' USER_INFO_LINK = 'https://www.googleapis.com/oauth2/v1/userinfo' -FLAGS = gflags.FLAGS - -gflags.DEFINE_string('test', None, 'Name of the test') -gflags.DEFINE_string('email', None, 'gmail id') -gflags.DEFINE_string('server_address', 'localhost:50052', 'Address of the performance database server') -gflags.DEFINE_string('tokens_dir', DEFAULT_ACCESS_TOKENS_DIR, 'Location of the access tokens') +parser = argparse.ArgumentParser(description='Report metrics to performance database') +parser.add_argument('--test', type=str, help='Name of the test to be executed') +parser.add_argument('--email', type=str, help='Gmail address of the user') +parser.add_argument('--server_address', type=str, default='localhost:50052', help='Address of the performance database server') +parser.add_argument('--tokens_dir', type=str, default=os.path.expanduser('~')+'/.grpc/access_tokens', help='Path to the access tokens directory') # Fetches JSON reply object, given a url and parameters def fetchJSON(url, paramDict): @@ -145,6 +143,11 @@ def refreshAccessToken(refreshToken, userTokFile): return data['access_token'] def reauthenticate(tokensDir): + # Create folder if not created already + if not os.path.exists(tokensDir): + os.makedirs(tokensDir) + os.chmod(tokensDir, 0700) + # Request parameters paramDict = {'client_id':CLIENT_ID, 'scope':'email profile'} JSONBody = fetchJSON(GOOGLE_ACCOUNTS_LINK, paramDict) @@ -170,6 +173,7 @@ def reauthenticate(tokensDir): # Write tokens to file with open(newUserTokFile, "w") as data_file: + os.chmod(newUserTokFile, 0600) json.dump(authData, data_file) # return working access token @@ -244,34 +248,26 @@ def getSysInfo(): return sysInfo def main(argv): - try: - argv = FLAGS(argv) - except Exception, e: - print '%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS) - sys.exit(1) + args = parser.parse_args() - tokensDir = FLAGS.tokens_dir - - # If tokens directory does not exist, creates it - if not os.path.exists(tokensDir): - os.makedirs(tokensDir) + tokensDir = args.tokens_dir try: # Fetch working access token - accessToken = getAccessToken(FLAGS.email, tokensDir) + accessToken = getAccessToken(args.email, tokensDir) except AttributeError: print '\nError: Please provide email address as an argument\n' sys.exit(1) - except: - print '\nError in authentication\n' + except Exception, e: + print e, ' \nError in authentication\n' sys.exit(1) # Address of the performance database server - serverAddress = FLAGS.server_address + serverAddress = args.server_address # Get path to test try: - testPath = findTestPath(FLAGS.test) + testPath = findTestPath(args.test) except TypeError: print '\nError: Please provide test name/path as argument\n' sys.exit(1) From c3cd4780df01e55a145c571074c5f31b13d9d864 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Fri, 19 Jun 2015 17:05:19 -0700 Subject: [PATCH 018/124] minor commented code removal --- test/cpp/qps/report.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 3d71f76fd22..b8ad4cf332a 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -118,10 +118,6 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) const { [](ResourceUsage u) { return u.wall_time; })); } -// perfDbClient perfDbClient(grpc::CreateChannel("localhost:50052", grpc::InsecureCredentials(), -// ChannelArguments())); - -//Performance database reporter implementation. void PerfDbReporter::ReportQPS(const ScenarioResult& result) const { auto qps = result.latencies.Count() / average(result.client_resources, From 373ad4d0d0ab1d9f970fc9a8d51526db2b48952b Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 22 Jun 2015 11:36:17 -0700 Subject: [PATCH 019/124] edited report --- test/cpp/qps/report.cc | 20 ++++++++++---------- test/cpp/qps/report.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index b8ad4cf332a..9bb15ea2111 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -123,8 +123,8 @@ void PerfDbReporter::ReportQPS(const ScenarioResult& result) const { average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - perfDbClient.setQPS(qps); - perfDbClient.setConfigs(result.client_config, result.server_config); + perfDbClient_.setQPS(qps); + perfDbClient_.setConfigs(result.client_config, result.server_config); } void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) const { @@ -134,18 +134,18 @@ void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) const { auto qpsPerCore = qps / result.server_config.threads(); - perfDbClient.setQPS(qps); - perfDbClient.setQPSPerCore(qpsPerCore); - perfDbClient.setConfigs(result.client_config, result.server_config); + perfDbClient_.setQPS(qps); + perfDbClient_.setQPSPerCore(qpsPerCore); + perfDbClient_.setConfigs(result.client_config, result.server_config); } void PerfDbReporter::ReportLatency(const ScenarioResult& result) const { - perfDbClient.setLatencies(result.latencies.Percentile(50) / 1000, + perfDbClient_.setLatencies(result.latencies.Percentile(50) / 1000, result.latencies.Percentile(90) / 1000, result.latencies.Percentile(95) / 1000, result.latencies.Percentile(99) / 1000, result.latencies.Percentile(99.9) / 1000); - perfDbClient.setConfigs(result.client_config, result.server_config); + perfDbClient_.setConfigs(result.client_config, result.server_config); } void PerfDbReporter::ReportTimes(const ScenarioResult& result) const { @@ -166,14 +166,14 @@ void PerfDbReporter::ReportTimes(const ScenarioResult& result) const { sum(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - perfDbClient.setTimes(serverSystemTime, serverUserTime, + perfDbClient_.setTimes(serverSystemTime, serverUserTime, clientSystemTime, clientUserTime); - perfDbClient.setConfigs(result.client_config, result.server_config); + perfDbClient_.setConfigs(result.client_config, result.server_config); } void PerfDbReporter::SendData() const { //send data to performance database - int dataState = perfDbClient.sendData(access_token_, test_name_, sys_info_); + int dataState = perfDbClient_.sendData(access_token_, test_name_, sys_info_); //check state of data sending switch(dataState) { diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index afc79ff75fc..1ea33755d45 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -41,7 +41,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/qpstest.grpc.pb.h" -#include "perf_db_client.h" +#include "test/cpp/qps/perf_db_client.h" namespace grpc { namespace testing { @@ -104,7 +104,7 @@ class GprLogReporter : public Reporter { void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; }; -/** Reporter for client leaderboard. */ +/** Reporter for performance database tool */ class PerfDbReporter : public Reporter { public: PerfDbReporter(const string& name, const string& access_token, const string& test_name, const string& sys_info, const string& server_address) @@ -114,7 +114,7 @@ class PerfDbReporter : public Reporter { ~PerfDbReporter() { SendData(); }; private: - PerfDbClient perfDbClient; + PerfDbClient perfDbClient_; std::string access_token_; std::string test_name_; std::string sys_info_; From 43645466681022f31bf2305b01bd7fab25369695 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 22 Jun 2015 12:21:57 -0700 Subject: [PATCH 020/124] Applied required modifications --- test/cpp/qps/perf_db.proto | 78 ++++----- test/cpp/qps/perf_db_client.cc | 14 +- test/cpp/qps/perf_db_client.h | 38 ++-- test/cpp/qps/report.cc | 10 +- test/cpp/qps/report.h | 12 +- test/cpp/qps/run_perf_db_test.py | 289 ------------------------------- 6 files changed, 76 insertions(+), 365 deletions(-) delete mode 100755 test/cpp/qps/run_perf_db_test.py diff --git a/test/cpp/qps/perf_db.proto b/test/cpp/qps/perf_db.proto index f4f174937c0..50070fda5b6 100644 --- a/test/cpp/qps/perf_db.proto +++ b/test/cpp/qps/perf_db.proto @@ -27,7 +27,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -syntax = "proto2"; +syntax = "proto3"; import "test/cpp/qps/qpstest.proto"; @@ -44,58 +44,58 @@ service PerfDbTransfer { //Metrics to be stored message Metrics { - optional double qps = 1; - optional double qps_per_core = 2; - optional double perc_lat_50 = 3; - optional double perc_lat_90 = 4; - optional double perc_lat_95 = 5; - optional double perc_lat_99 = 6; - optional double perc_lat_99_point_9 = 7; - optional double server_system_time = 8; - optional double server_user_time = 9; - optional double client_system_time = 10; - optional double client_user_time = 11; + double qps = 1; + double qps_per_core = 2; + double perc_lat_50 = 3; + double perc_lat_90 = 4; + double perc_lat_95 = 5; + double perc_lat_99 = 6; + double perc_lat_99_point_9 = 7; + double server_system_time = 8; + double server_user_time = 9; + double client_system_time = 10; + double client_user_time = 11; } //Timestamped details message DataDetails { - optional string timestamp = 1; - optional string test_name = 2; - optional string sys_info = 3; - optional Metrics metrics = 4; - optional ClientConfig client_config = 5; - optional ServerConfig server_config = 6; + string timestamp = 1; + string test_name = 2; + string sys_info = 3; + Metrics metrics = 4; + ClientConfig client_config = 5; + ServerConfig server_config = 6; } //User details message UserDetails { - optional string id = 1; - optional string email = 2; - optional bool verified_email = 3; - optional string name = 4; - optional string given_name = 5; - optional string family_name = 6; - optional string link = 7; - optional string picture = 8; - optional string gender = 9; - optional string locale = 10; - optional string hd = 11; + string id = 1; + string email = 2; + bool verified_email = 3; + string name = 4; + string given_name = 5; + string family_name = 6; + string link = 7; + string picture = 8; + string gender = 9; + string locale = 10; + string hd = 11; } //Stored to database message SingleUserDetails { repeated DataDetails data_details = 1; - optional UserDetails user_details = 2; + UserDetails user_details = 2; } //Request for storing a single user's data message SingleUserRecordRequest { - optional string access_token = 1; - optional string test_name = 2; - optional string sys_info = 3; - optional Metrics metrics = 4; - optional ClientConfig client_config = 5; - optional ServerConfig server_config = 6; + string access_token = 1; + string test_name = 2; + string sys_info = 3; + Metrics metrics = 4; + ClientConfig client_config = 5; + ServerConfig server_config = 6; } //Reply to request for storing single user's data @@ -104,12 +104,12 @@ message SingleUserRecordReply { //Request for retrieving single user's data message SingleUserRetrieveRequest { - optional string user_id = 1; + string user_id = 1; } //Reply for request to retrieve single user's data message SingleUserRetrieveReply { - optional SingleUserDetails details = 1; + SingleUserDetails details = 1; } //Request for retrieving all users' data @@ -119,4 +119,4 @@ message AllUsersRetrieveReply { //Reply to request for retrieving all users' data message AllUsersRetrieveRequest { -} \ No newline at end of file +} diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 6a1fe7e26e7..5b929087669 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -31,30 +31,30 @@ * */ -#include "perf_db_client.h" +#include "test/cpp/qps/perf_db_client.h" namespace grpc { namespace testing { //sets the client and server config information -void PerfDbClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) const { +void PerfDbClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) { clientConfig_ = clientConfig; serverConfig_ = serverConfig; } //sets the QPS -void PerfDbClient::setQPS(double QPS) const { +void PerfDbClient::setQPS(double QPS) { QPS_ = QPS; } //sets the QPS per core -void PerfDbClient::setQPSPerCore(double QPSPerCore) const { +void PerfDbClient::setQPSPerCore(double QPSPerCore) { QPSPerCore_ = QPSPerCore; } //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency void PerfDbClient::setLatencies(double percentileLatency50, double percentileLatency90, - double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) const { + double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) { percentileLatency50_ = percentileLatency50; percentileLatency90_ = percentileLatency90; percentileLatency95_ = percentileLatency95; @@ -64,7 +64,7 @@ void PerfDbClient::setLatencies(double percentileLatency50, double percentileLat //sets the server and client, user and system times void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, - double clientSystemTime, double clientUserTime) const { + double clientSystemTime, double clientUserTime) { serverSystemTime_ = serverSystemTime; serverUserTime_ = serverUserTime; clientSystemTime_ = clientSystemTime; @@ -72,7 +72,7 @@ void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, } //sends the data to the performancew database server -int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info) const { +int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info) { //Data record request object SingleUserRecordRequest singleUserRecordRequest; diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index 4a63dbf3d28..058cd6a2070 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -59,40 +59,40 @@ public: ~PerfDbClient() {} //sets the client and server config information - void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) const; + void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig); //sets the QPS - void setQPS(double QPS) const; + void setQPS(double QPS); //sets the QPS per core - void setQPSPerCore(double QPSPerCore) const; + void setQPSPerCore(double QPSPerCore); //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency void setLatencies(double percentileLatency50, double percentileLatency90, - double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) const; + double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); //sets the server and client, user and system times void setTimes(double serverSystemTime, double serverUserTime, - double clientSystemTime, double clientUserTime) const; + double clientSystemTime, double clientUserTime); //sends the data to the performancew database server - int sendData(std::string access_token, std::string test_name, std::string sys_info) const; + int sendData(std::string access_token, std::string test_name, std::string sys_info); private: std::unique_ptr stub_; - mutable ClientConfig clientConfig_; - mutable ServerConfig serverConfig_; - mutable double QPS_ = DBL_MIN; - mutable double QPSPerCore_ = DBL_MIN; - mutable double percentileLatency50_ = DBL_MIN; - mutable double percentileLatency90_ = DBL_MIN; - mutable double percentileLatency95_ = DBL_MIN; - mutable double percentileLatency99_ = DBL_MIN; - mutable double percentileLatency99Point9_ = DBL_MIN; - mutable double serverSystemTime_ = DBL_MIN; - mutable double serverUserTime_ = DBL_MIN; - mutable double clientSystemTime_ = DBL_MIN; - mutable double clientUserTime_ = DBL_MIN; + ClientConfig clientConfig_; + ServerConfig serverConfig_; + double QPS_ = DBL_MIN; + double QPSPerCore_ = DBL_MIN; + double percentileLatency50_ = DBL_MIN; + double percentileLatency90_ = DBL_MIN; + double percentileLatency95_ = DBL_MIN; + double percentileLatency99_ = DBL_MIN; + double percentileLatency99Point9_ = DBL_MIN; + double serverSystemTime_ = DBL_MIN; + double serverUserTime_ = DBL_MIN; + double clientSystemTime_ = DBL_MIN; + double clientUserTime_ = DBL_MIN; }; } //namespace testing diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 47d602a4c2e..59c0da31fb9 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -118,7 +118,7 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) { [](ResourceUsage u) { return u.wall_time; })); } -void PerfDbReporter::ReportQPS(const ScenarioResult& result) const { +void PerfDbReporter::ReportQPS(const ScenarioResult& result) { auto qps = result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); @@ -127,7 +127,7 @@ void PerfDbReporter::ReportQPS(const ScenarioResult& result) const { perfDbClient_.setConfigs(result.client_config, result.server_config); } -void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) const { +void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) { auto qps = result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); @@ -139,7 +139,7 @@ void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) const { perfDbClient_.setConfigs(result.client_config, result.server_config); } -void PerfDbReporter::ReportLatency(const ScenarioResult& result) const { +void PerfDbReporter::ReportLatency(const ScenarioResult& result) { perfDbClient_.setLatencies(result.latencies.Percentile(50) / 1000, result.latencies.Percentile(90) / 1000, result.latencies.Percentile(95) / 1000, @@ -148,7 +148,7 @@ void PerfDbReporter::ReportLatency(const ScenarioResult& result) const { perfDbClient_.setConfigs(result.client_config, result.server_config); } -void PerfDbReporter::ReportTimes(const ScenarioResult& result) const { +void PerfDbReporter::ReportTimes(const ScenarioResult& result) { double serverSystemTime = 100.0 * sum(result.server_resources, [](ResourceUsage u) { return u.system_time; }) / sum(result.server_resources, @@ -171,7 +171,7 @@ void PerfDbReporter::ReportTimes(const ScenarioResult& result) const { perfDbClient_.setConfigs(result.client_config, result.server_config); } -void PerfDbReporter::SendData() const { +void PerfDbReporter::SendData() { //send data to performance database int dataState = perfDbClient_.sendData(access_token_, test_name_, sys_info_); diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 2ec7fe73f0d..bba26b990cf 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -109,7 +109,7 @@ class PerfDbReporter : public Reporter { public: PerfDbReporter(const string& name, const string& access_token, const string& test_name, const string& sys_info, const string& server_address) : Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info) { - perfDbClient.init(grpc::CreateChannel(server_address, grpc::InsecureCredentials(), ChannelArguments())); + perfDbClient_.init(grpc::CreateChannel(server_address, grpc::InsecureCredentials(), ChannelArguments())); } ~PerfDbReporter() { SendData(); }; @@ -118,11 +118,11 @@ class PerfDbReporter : public Reporter { std::string access_token_; std::string test_name_; std::string sys_info_; - void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; - void ReportQPSPerCore(const ScenarioResult& result) const GRPC_OVERRIDE; - void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; - void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; - void SendData() const; + void ReportQPS(const ScenarioResult& result) GRPC_OVERRIDE; + void ReportQPSPerCore(const ScenarioResult& result) GRPC_OVERRIDE; + void ReportLatency(const ScenarioResult& result) GRPC_OVERRIDE; + void ReportTimes(const ScenarioResult& result) GRPC_OVERRIDE; + void SendData(); }; } // namespace testing diff --git a/test/cpp/qps/run_perf_db_test.py b/test/cpp/qps/run_perf_db_test.py deleted file mode 100755 index a8e69ea1f02..00000000000 --- a/test/cpp/qps/run_perf_db_test.py +++ /dev/null @@ -1,289 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -import os -import sys -import re -import urllib2 -import urllib -import json -import time -import subprocess -import fnmatch -import argparse - -CLIENT_ID = '1018396037782-tv81fshn76nemr24uuhuginceb9hni2m.apps.googleusercontent.com' -CLIENT_SECRET = '_HGHXg4DAA59r4w4x8p6ARzD' -GRANT_TYPE = 'http://oauth.net/grant_type/device/1.0' -AUTH_TOKEN_LINK = 'https://www.googleapis.com/oauth2/v3/token' -GOOGLE_ACCOUNTS_LINK = 'https://accounts.google.com/o/oauth2/device/code' -USER_INFO_LINK = 'https://www.googleapis.com/oauth2/v1/userinfo' - -parser = argparse.ArgumentParser(description='Report metrics to performance database') -parser.add_argument('--test', type=str, help='Name of the test to be executed') -parser.add_argument('--email', type=str, help='Gmail address of the user') -parser.add_argument('--server_address', type=str, default='localhost:50052', help='Address of the performance database server') -parser.add_argument('--tokens_dir', type=str, default=os.path.expanduser('~')+'/.grpc/access_tokens', help='Path to the access tokens directory') - -# Fetches JSON reply object, given a url and parameters -def fetchJSON(url, paramDict): - if len(paramDict) == 0: - req = urllib2.Request(url) - else: - data = urllib.urlencode(paramDict) - req = urllib2.Request(url, data) - - try: - response = urllib2.urlopen(req) - result = response.read() - - except urllib2.HTTPError, error: - result = error.read() - - return result - -# Fetch user info; used to check if access token is valid -def getUserInfo(accessToken): - url = USER_INFO_LINK + '?access_token=' + accessToken - paramDict = {} - JSONBody = fetchJSON(url, paramDict) - data = json.loads(JSONBody) - - return data - -# Returns true if stored access token is valid -def isAccessTokenValid(accessToken): - data = getUserInfo(accessToken); - - if 'id' in data: - return True - else: - return False - -# Returns user id given a working access token -def getUserId(accessToken): - data = getUserInfo(accessToken) - - email = data['email'] - userId = getUserIdFromEmail(email) - - return userId - -# Extracts a unique user id from an email address -def getUserIdFromEmail(email): - email = email.split('@')[0].lower() # take username and convert to lower case - userId = re.sub('[.]', '', email) # remove periods - - return userId - -# Use an existing access token -def useAccessToken(userTokFile): - with open(userTokFile, "r") as data_file: - data = json.load(data_file) # load JSON data from file - accessToken = data["access_token"] - - # If access token has gone stale, refresh it - if not isAccessTokenValid(accessToken): - return refreshAccessToken(data["refresh_token"], userTokFile) - - return accessToken - -# refresh stale access token -def refreshAccessToken(refreshToken, userTokFile): - # Parameters for request - paramDict = {'refresh_token':refreshToken, 'client_id':CLIENT_ID, 'client_secret':CLIENT_SECRET, 'grant_type':'refresh_token'} - # Fetch reply to request - JSONBody = fetchJSON(AUTH_TOKEN_LINK, paramDict) - data = json.loads(JSONBody) - - if not 'access_token' in data: - # Refresh token has gone stale, re-authentication required - return reauthenticate() - else: - # write fresh access token to tokens file - tokenData = {} - - with open(userTokFile, "r") as data_file: - tokenData = json.load(data_file) - - with open(userTokFile, "w") as data_file: - tokenData['access_token'] = data['access_token'] - json.dump(tokenData, data_file) - - # return fresh access token - return data['access_token'] - -def reauthenticate(tokensDir): - # Create folder if not created already - if not os.path.exists(tokensDir): - os.makedirs(tokensDir) - os.chmod(tokensDir, 0700) - - # Request parameters - paramDict = {'client_id':CLIENT_ID, 'scope':'email profile'} - JSONBody = fetchJSON(GOOGLE_ACCOUNTS_LINK, paramDict) - data = json.loads(JSONBody) - - print 'User authorization required\n' - print 'Please use the following code in you browser: ', data['user_code'] # Code to be entered by user in browser - print 'Verification URL: ', data['verification_url'] # Authentication link - print '\nAwaiting user authorization. May take a few more seconds after authorizing...\n' - - authData = {} - - while not 'access_token' in authData: - # Request parameters - authDict = {'client_id':CLIENT_ID, 'client_secret':CLIENT_SECRET, 'code':data['device_code'], 'grant_type':GRANT_TYPE} - JSONBody = fetchJSON(AUTH_TOKEN_LINK, authDict) - authData = json.loads(JSONBody) - # If server pinged too quickly, will get slowdown message; need to wait for specified interval - time.sleep(data['interval']) - - # File to write tokens - newUserTokFile = tokensDir + '/' + getUserId(authData['access_token']) - - # Write tokens to file - with open(newUserTokFile, "w") as data_file: - os.chmod(newUserTokFile, 0600) - json.dump(authData, data_file) - - # return working access token - return authData['access_token'] - -# Fetch a working access token given user entered email id; authntication may be required -def getAccessToken(email, tokensDir): - # Get unique user id from email address - userId = getUserIdFromEmail(email) - - # Token file - userTokFile = tokensDir + '/' + userId - - accessToken = '' - - if os.path.exists(userTokFile): - # File containing access token exists; unless refresh token has expired, user authentication will not be required - accessToken = useAccessToken(userTokFile) - else: - # User authentication required - accessToken = reauthenticate(tokensDir) - - return accessToken - -# If user has not entered full path to test, recursively searches for given test in parent folders -def findTestPath(test): - # If user entered full path to test, return it - if(os.path.isfile(test)): - return test - - testName = test.split('/')[-1] # Extract just test name - testPath = '' - - # Search for test - for root, dirnames, filenames in os.walk('../../../'): - for fileName in fnmatch.filter(filenames, testName): - testPath = os.path.join(root, fileName) - - return testPath - -def getSysInfo(): - # Fetch system information - sysInfo = os.popen('lscpu').readlines() - - NICs = os.popen('ifconfig | cut -c1-8 | sed \'/^\s*$/d\' | sort -u').readlines() - nicAddrs = os.popen('ifconfig | grep -oE "inet addr:([0-9]{1,3}\.){3}[0-9]{1,3}"').readlines() - - nicInfo = [] - - for i in range(0, len(NICs)): - NIC = NICs[i] - NIC = re.sub(r'[^\w]', '', NIC) - - ethtoolProcess = subprocess.Popen(["ethtool",NIC], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - ethtoolResult = ethtoolProcess.communicate()[0] - - ethtoolResultList = ethtoolResult.split('\n\t') - for ethtoolString in ethtoolResultList: - if ethtoolString.startswith('Speed'): - ethtoolString = ethtoolString.split(':')[1] - ethtoolString = ethtoolString.replace('Mb/s',' Mbps') - nicInfo.append('NIC ' + NIC + ' speed: ' + ethtoolString + '\n') - nicInfo.append(NIC + ' inet address: ' + nicAddrs[i].split(':')[1]) - - print 'Obtaining network info....' - tcp_rr_rate = str(os.popen('netperf -t TCP_RR -v 0').readlines()[1]) - print 'Network info obtained' - - nicInfo.append('TCP RR transmission rate per sec: ' + tcp_rr_rate + '\n') - sysInfo = sysInfo + nicInfo - - return sysInfo - -def main(argv): - args = parser.parse_args() - - tokensDir = args.tokens_dir - - try: - # Fetch working access token - accessToken = getAccessToken(args.email, tokensDir) - except AttributeError: - print '\nError: Please provide email address as an argument\n' - sys.exit(1) - except Exception, e: - print e, ' \nError in authentication\n' - sys.exit(1) - - # Address of the performance database server - serverAddress = args.server_address - - # Get path to test - try: - testPath = findTestPath(args.test) - except TypeError: - print '\nError: Please provide test name/path as argument\n' - sys.exit(1) - - # Get name of the test - testName = testPath.split('/')[-1] - - # Get the system information - sysInfo = getSysInfo() - - try: - print '\nBeginning test:\n' - # Run the test - subprocess.call([testPath, '--report_metrics_db=true', '--access_token='+accessToken, '--test_name='+testName, '--sys_info='+str(sysInfo).strip('[]'), '--server_address='+serverAddress]) - except OSError: - print 'Could not execute the test' - -if __name__ == "__main__": - main(sys.argv) \ No newline at end of file From 60111c0df846522c195a690abb01b6c536ff54a1 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 22 Jun 2015 13:02:33 -0700 Subject: [PATCH 021/124] updated syntax based errors --- test/cpp/qps/perf_db_client.cc | 26 ++++++++++++------------ test/cpp/qps/perf_db_client.h | 36 ++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 5b929087669..9ae8ba36fff 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -38,37 +38,37 @@ namespace testing { //sets the client and server config information void PerfDbClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) { - clientConfig_ = clientConfig; - serverConfig_ = serverConfig; + this->clientConfig_ = clientConfig; + this->serverConfig_ = serverConfig; } //sets the QPS void PerfDbClient::setQPS(double QPS) { - QPS_ = QPS; + this->QPS_ = QPS; } //sets the QPS per core void PerfDbClient::setQPSPerCore(double QPSPerCore) { - QPSPerCore_ = QPSPerCore; + this->QPSPerCore_ = QPSPerCore; } //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency void PerfDbClient::setLatencies(double percentileLatency50, double percentileLatency90, double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) { - percentileLatency50_ = percentileLatency50; - percentileLatency90_ = percentileLatency90; - percentileLatency95_ = percentileLatency95; - percentileLatency99_ = percentileLatency99; - percentileLatency99Point9_ = percentileLatency99Point9; + this->percentileLatency50_ = percentileLatency50; + this->percentileLatency90_ = percentileLatency90; + this->percentileLatency95_ = percentileLatency95; + this->percentileLatency99_ = percentileLatency99; + this->percentileLatency99Point9_ = percentileLatency99Point9; } //sets the server and client, user and system times void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, double clientSystemTime, double clientUserTime) { - serverSystemTime_ = serverSystemTime; - serverUserTime_ = serverUserTime; - clientSystemTime_ = clientSystemTime; - clientUserTime_ = clientUserTime; + this->serverSystemTime_ = serverSystemTime; + this->serverUserTime_ = serverUserTime; + this->clientSystemTime_ = clientSystemTime; + this->clientUserTime_ = clientUserTime; } //sends the data to the performancew database server diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index 058cd6a2070..c19442f35e5 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -52,7 +52,19 @@ namespace testing { //Manages data sending to performance database server class PerfDbClient { public: - PerfDbClient() {} + PerfDbClient() { + QPS_ = DBL_MIN; + QPSPerCore_ = DBL_MIN; + percentileLatency50_ = DBL_MIN; + percentileLatency90_ = DBL_MIN; + percentileLatency95_ = DBL_MIN; + percentileLatency99_ = DBL_MIN; + percentileLatency99Point9_ = DBL_MIN; + serverSystemTime_ = DBL_MIN; + serverUserTime_ = DBL_MIN; + clientSystemTime_ = DBL_MIN; + clientUserTime_ = DBL_MIN; + } void init(std::shared_ptr channel) { stub_ = PerfDbTransfer::NewStub(channel); } @@ -82,17 +94,17 @@ private: std::unique_ptr stub_; ClientConfig clientConfig_; ServerConfig serverConfig_; - double QPS_ = DBL_MIN; - double QPSPerCore_ = DBL_MIN; - double percentileLatency50_ = DBL_MIN; - double percentileLatency90_ = DBL_MIN; - double percentileLatency95_ = DBL_MIN; - double percentileLatency99_ = DBL_MIN; - double percentileLatency99Point9_ = DBL_MIN; - double serverSystemTime_ = DBL_MIN; - double serverUserTime_ = DBL_MIN; - double clientSystemTime_ = DBL_MIN; - double clientUserTime_ = DBL_MIN; + double QPS_; + double QPSPerCore_; + double percentileLatency50_; + double percentileLatency90_; + double percentileLatency95_; + double percentileLatency99_; + double percentileLatency99Point9_; + double serverSystemTime_; + double serverUserTime_; + double clientSystemTime_; + double clientUserTime_; }; } //namespace testing From a4de070c69d81b1a79e7727a6b342a6b248daaa6 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 22 Jun 2015 13:05:26 -0700 Subject: [PATCH 022/124] Further corrections to syntax --- test/cpp/qps/perf_db_client.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 9ae8ba36fff..0905cde11a0 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -82,23 +82,23 @@ int PerfDbClient::sendData(std::string access_token, std::string test_name, std: singleUserRecordRequest.set_sys_info(sys_info); //setting configs - *(singleUserRecordRequest.mutable_client_config()) = clientConfig_; - *(singleUserRecordRequest.mutable_server_config()) = serverConfig_; + *(singleUserRecordRequest.mutable_client_config()) = this->clientConfig_; + *(singleUserRecordRequest.mutable_server_config()) = this->serverConfig_; Metrics* metrics = singleUserRecordRequest.mutable_metrics(); //setting metrcs in data record request - if(QPS_ != DBL_MIN) metrics->set_qps(QPS_); - if(QPSPerCore_ != DBL_MIN) metrics->set_qps_per_core(QPSPerCore_); - if(percentileLatency50_ != DBL_MIN) metrics->set_perc_lat_50(percentileLatency50_); - if(percentileLatency90_ != DBL_MIN) metrics->set_perc_lat_90(percentileLatency90_); - if(percentileLatency95_ != DBL_MIN) metrics->set_perc_lat_95(percentileLatency95_); - if(percentileLatency99_ != DBL_MIN) metrics->set_perc_lat_99(percentileLatency99_); - if(percentileLatency99Point9_ != DBL_MIN) metrics->set_perc_lat_99_point_9(percentileLatency99Point9_); - if(serverSystemTime_ != DBL_MIN) metrics->set_server_system_time(serverSystemTime_); - if(serverUserTime_ != DBL_MIN) metrics->set_server_user_time(serverUserTime_); - if(clientSystemTime_ != DBL_MIN) metrics->set_client_system_time(clientSystemTime_); - if(clientUserTime_ != DBL_MIN) metrics->set_client_user_time(clientUserTime_); + if(QPS_ != DBL_MIN) metrics->set_qps(this->QPS_); + if(QPSPerCore_ != DBL_MIN) metrics->set_qps_per_core(this->QPSPerCore_); + if(percentileLatency50_ != DBL_MIN) metrics->set_perc_lat_50(this->percentileLatency50_); + if(percentileLatency90_ != DBL_MIN) metrics->set_perc_lat_90(this->percentileLatency90_); + if(percentileLatency95_ != DBL_MIN) metrics->set_perc_lat_95(this->percentileLatency95_); + if(percentileLatency99_ != DBL_MIN) metrics->set_perc_lat_99(this->percentileLatency99_); + if(percentileLatency99Point9_ != DBL_MIN) metrics->set_perc_lat_99_point_9(this->percentileLatency99Point9_); + if(serverSystemTime_ != DBL_MIN) metrics->set_server_system_time(this->serverSystemTime_); + if(serverUserTime_ != DBL_MIN) metrics->set_server_user_time(this->serverUserTime_); + if(clientSystemTime_ != DBL_MIN) metrics->set_client_system_time(this->clientSystemTime_); + if(clientUserTime_ != DBL_MIN) metrics->set_client_user_time(this->clientUserTime_); SingleUserRecordReply singleUserRecordReply; ClientContext context; From ca241639c65cd5491434bfe0dc021e38b40008c5 Mon Sep 17 00:00:00 2001 From: sidrakesh93 Date: Mon, 22 Jun 2015 14:26:41 -0700 Subject: [PATCH 023/124] Update perf_db_client.cc --- test/cpp/qps/perf_db_client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 0905cde11a0..f514408c14c 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -111,4 +111,4 @@ int PerfDbClient::sendData(std::string access_token, std::string test_name, std: } } } //testing -} //grpc \ No newline at end of file +} //grpc From 9d0e047a5caba99194e6ed377ac0234f3907d6a3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 23 Jun 2015 09:12:48 -0700 Subject: [PATCH 024/124] Client configuration libary - headers & docs Initial sketch of a client configuration library. It's expected this will subsume the client_setup functionality that we currently have, and begin providing customizable load balancing support. Releasing the headers now (no implementation work has been done) so that we can bat around thoughts on this and make sure all the use cases are implementable, and our primary use cases are easily so. --- src/core/client_config/README.md | 45 ++++++++++ src/core/client_config/client_config.h | 49 +++++++++++ .../client_config/configured_subchannel.h | 72 ++++++++++++++++ .../configured_subchannel_factory.h | 86 +++++++++++++++++++ src/core/client_config/lb_policy.h | 73 ++++++++++++++++ src/core/client_config/resolver.h | 75 ++++++++++++++++ 6 files changed, 400 insertions(+) create mode 100644 src/core/client_config/README.md create mode 100644 src/core/client_config/client_config.h create mode 100644 src/core/client_config/configured_subchannel.h create mode 100644 src/core/client_config/configured_subchannel_factory.h create mode 100644 src/core/client_config/lb_policy.h create mode 100644 src/core/client_config/resolver.h diff --git a/src/core/client_config/README.md b/src/core/client_config/README.md new file mode 100644 index 00000000000..316f9b1cc9d --- /dev/null +++ b/src/core/client_config/README.md @@ -0,0 +1,45 @@ +Client Configuration Support for GRPC +===================================== + +This library provides high level configuration machinery to construct client +channels and load balance between them. + +Each grpc_channel is created with a grpc_resolver. It is the resolver's duty +to resolve a name into configuration data for the channel. Such configuration +data might include: + +- a list of (ip, port) addresses to connect to +- a load balancing policy to decide which server to send a request to +- a set of filters to mutate outgoing requests (say, by adding metadata) + +The resolver provides this data as a stream of grpc_client_config objects to +the channel. We represent configuration as a stream so that it can be changed +by the resolver during execution, by reacting to external events (such as a +new configuration file being pushed to some store). + + +Load Balancing +-------------- + +Load balancing configuration is provided by a grpc_lb_policy object, stored as +part of grpc_client_config. + +A load balancing policies primary job is to pick a target server given only the +initial metadata for a request. It does this by providing a +grpc_configured_channel object to the owning channel. + + +Configured Sub-Channels +----------------------- + +A configured sub-channel provides a connection to a server for a client +channel. It has a connectivity state like a regular channel, and so can be +connected or disconnected. This connectivity state can be used to inform load +balancing decisions (for example, by avoiding disconnected backends). + +Configured sub-channels are fully setup to participate in the grpc data plane. +Their behavior is specified by a set of grpc channel filters defined at their +construction. To customize this behavior, resolvers build +grpc_configured_subchannel_factory objects, which use the decorator pattern +to customize construction arguments for concrete grpc_configured_subchannel +instances. diff --git a/src/core/client_config/client_config.h b/src/core/client_config/client_config.h new file mode 100644 index 00000000000..7974e24bc3c --- /dev/null +++ b/src/core/client_config/client_config.h @@ -0,0 +1,49 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H + +/** Total configuration for a client. Provided, and updated, by + grpc_resolver */ +typedef struct grpc_client_config grpc_client_config; + +void grpc_client_config_ref(grpc_client_config *client_config); +void grpc_client_config_unref(grpc_client_config *client_config); + +void grpc_client_config_set_lb_policy(grpc_client_config *client_config, + grpc_lb_policy *lb_policy); +grpc_lb_policy *grpc_client_config_get_lb_policy( + grpc_client_config *client_config); + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H */ diff --git a/src/core/client_config/configured_subchannel.h b/src/core/client_config/configured_subchannel.h new file mode 100644 index 00000000000..e2e7cf8a1a1 --- /dev/null +++ b/src/core/client_config/configured_subchannel.h @@ -0,0 +1,72 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_H + +/** A (sub-)channel that knows how to connect to exactly one target + address. Provides a target for load balancing. */ +typedef struct grpc_configured_subchannel grpc_configured_subchannel; + +/** Connectivity state of a channel. + TODO(ctiller): move to grpc.h when we implement the public + version of the connectivity apis */ +typedef enum { + /** channel is connecting */ + GRPC_CHANNEL_CONNECTING, + /** channel is ready for work */ + GRPC_CHANNEL_READY, + /** channel has seen a failure but expects to recover */ + GRPC_CHANNEL_TRANSIENT_FAILURE, + /** channel is idle */ + GRPC_CHANNEL_IDLE, + /** channel has seen a failure that it cannot recover from */ + GRPC_CHANNEL_FATAL_FAILURE +} grpc_connectivity_state; + +void grpc_configured_subchannel_ref(grpc_configured_subchannel *channel); +void grpc_configured_subchannel_unref(grpc_configured_subchannel *channel); + +/** poll the current connectivity state of a channel */ +grpc_connectivity_state grpc_configured_subchannel_check_connectivity( + grpc_configured_subchannel *channel); +/** call notify when the connectivity state of a channel changes from *state. + Updates *state with the new state of the channel */ +void grpc_configured_subchannel_notify_on_state_change( + grpc_configured_subchannel *channel, grpc_connectivity_state *state, + grpc_iomgr_closure *notify); +/** continue processing of transport operation \a op */ +void grpc_configured_subchannel_continue_op(grpc_configured_subchannel *channel, + grpc_transport_op *op); + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_H */ diff --git a/src/core/client_config/configured_subchannel_factory.h b/src/core/client_config/configured_subchannel_factory.h new file mode 100644 index 00000000000..6bfc8e44363 --- /dev/null +++ b/src/core/client_config/configured_subchannel_factory.h @@ -0,0 +1,86 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_FACTORY_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_FACTORY_H + +typedef struct grpc_configured_subchannel_factory + grpc_configured_subchannel_factory; +typedef struct grpc_configured_subchannel_factory_vtable + grpc_configured_subchannel_factory_vtable; + +/** Constructor for new configured channels. + Creating decorators around this type is encouraged to adapt behavior. */ +struct grpc_configured_subchannel_factory { + const grpc_configured_subchannel_factory_vtable *vtable; +}; + +struct grpc_configured_subchannel_args { + /* TODO(ctiller): consider making (parent, metadata_context) more opaque + - these details are not needed at this level of API */ + /** Parent channel element - passed from the master channel */ + grpc_channel_element *parent; + /** Metadata context for this channel - passed from the master channel */ + grpc_mdctx *metadata_context; + /** Channel filters for this channel - wrapped factories will likely + want to mutate this */ + const grpc_channel_filter **filters; + /** The number of filters in the above array */ + size_t filter_count; + /** Channel arguments to be supplied to the newly created channel */ + const grpc_channel_args *args; + + struct sockaddr *addr; +}; + +struct grpc_configured_subchannel_factory_vtable { + void (*ref)(grpc_configured_subchannel_factory *factory); + void (*unref)(grpc_configured_subchannel_factory *factory); + grpc_configured_subchannel *(*create_subchannel)( + grpc_configured_subchannel_factory *factory, + grpc_configured_subchannel_args *args); +}; + +void grpc_configured_subchannel_factory_ref( + grpc_configured_subchannel_factory *factory); +void grpc_configured_subchannel_factory_unref( + grpc_configured_subchannel_factory *factory); +/** Create a new grpc_configured_subchannel */ +void grpc_configured_subchannel_factory_create_subchannel( + grpc_configured_subchannel_factory *factory, + grpc_configured_subchannel_args *args); + +grpc_configured_subchannel_factory * +grpc_default_configured_subchannel_factory(); + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_FACTORY_H */ diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h new file mode 100644 index 00000000000..5cf81990472 --- /dev/null +++ b/src/core/client_config/lb_policy.h @@ -0,0 +1,73 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H + +#include "src/core/client_config/configured_channel.h" + +/** A load balancing policy: specified by a vtable and a struct (which + is expected to be extended to contain some parameters) */ +typedef struct grpc_lb_policy grpc_lb_policy; +typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable; + +typedef void (*grpc_lb_completion)(void *cb_arg, + grpc_configured_channel *configured_channel, + grpc_status_code status, const char *errmsg); + +struct grpc_lb_policy_vtable { + void (*ref)(grpc_lb_policy *policy); + void (*unref)(grpc_lb_policy *policy); + + void (*shutdown)(grpc_lb_policy *policy); + + /** implement grpc_lb_policy_pick */ + void (*pick)(grpc_lb_policy *policy, grpc_pollset *pollset, + grpc_metadata_batch *initial_metadata, + grpc_configured_channel **target, + grpc_iomgr_closure *on_complete); +}; + +/** Start shutting down (fail any pending picks) */ +void grpc_lb_policy_shutdown(grpc_lb_policy *policy); + +/** Given initial metadata in \a initial_metadata, find an appropriate + target for this rpc, and 'return' it by calling \a on_complete after setting + \a target. + Picking can be asynchronous. Any IO should be done under \a pollset. */ +void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset, + grpc_metadata_batch *initial_metadata, + grpc_configured_channel **target, + grpc_iomgr_closure *on_complete); + +#endif /* GRPC_INTERNAL_CORE_CONFIG_LB_POLICY_H */ diff --git a/src/core/client_config/resolver.h b/src/core/client_config/resolver.h new file mode 100644 index 00000000000..13672fb3eeb --- /dev/null +++ b/src/core/client_config/resolver.h @@ -0,0 +1,75 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_H + +typedef struct grpc_resolver grpc_resolver; +typedef struct grpc_resolver_vtable grpc_resolver_vtable; + +/** grpc_resolver provides grpc_client_config objects to grpc_channel + objects */ +struct grpc_resolver { + const grpc_resolver_vtable *vtable; +}; + +struct grpc_resolver_vtable { + void (*ref)(grpc_resolver *resolver); + void (*unref)(grpc_resolver *resolver); + void (*shutdown)(grpc_resolver *resolver); + void (*channel_saw_error)(grpc_resolver *resolver, + struct sockaddr *failing_address); + void (*next)(grpc_resolver *resolver, grpc_client_config **target_config, + grpc_iomgr_closure *on_complete); +}; + +void grpc_resolver_ref(grpc_resolver *resolver); +void grpc_resolver_unref(grpc_resolver *resolver); +void grpc_resolver_shutdown(grpc_resolver *resolver); + +/** Notification that the channel has seen an error on some address. + Can be used as a hint that re-resolution is desirable soon. */ +void grpc_resolver_channel_saw_error(grpc_resolver *resolver, + struct sockaddr *failing_address); + +/** Get the next client config. Called by the channel to fetch a new + configuration. Expected to set *target_config with a new configuration, + and then schedule on_complete for execution. + + If resolution is fatally broken, set *target_config to NULL and + schedule on_complete. */ +void grpc_resolver_next(grpc_resolver *resolver, + grpc_client_config **target_config, + grpc_iomgr_closure *on_complete); + +#endif /* GRPC_INTERNAL_CORE_CONFIG_RESOLVER_H */ From 9e8f9115c4e416a5ce3735e0b6cc47fce04973ef Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 23 Jun 2015 10:56:11 -0700 Subject: [PATCH 025/124] Rename configured_subchannel --> subchannel Per @a11r's request --- src/core/client_config/README.md | 23 +++++----- .../{configured_subchannel.h => subchannel.h} | 26 +++++------ ...channel_factory.h => subchannel_factory.h} | 45 ++++++++----------- 3 files changed, 43 insertions(+), 51 deletions(-) rename src/core/client_config/{configured_subchannel.h => subchannel.h} (74%) rename src/core/client_config/{configured_subchannel_factory.h => subchannel_factory.h} (63%) diff --git a/src/core/client_config/README.md b/src/core/client_config/README.md index 316f9b1cc9d..7cb19cd130e 100644 --- a/src/core/client_config/README.md +++ b/src/core/client_config/README.md @@ -25,21 +25,20 @@ Load balancing configuration is provided by a grpc_lb_policy object, stored as part of grpc_client_config. A load balancing policies primary job is to pick a target server given only the -initial metadata for a request. It does this by providing a -grpc_configured_channel object to the owning channel. +initial metadata for a request. It does this by providing a grpc_subchannel +object to the owning channel. -Configured Sub-Channels ------------------------ +Sub-Channels +------------ -A configured sub-channel provides a connection to a server for a client -channel. It has a connectivity state like a regular channel, and so can be -connected or disconnected. This connectivity state can be used to inform load -balancing decisions (for example, by avoiding disconnected backends). +A sub-channel provides a connection to a server for a client channel. It has a +connectivity state like a regular channel, and so can be connected or +disconnected. This connectivity state can be used to inform load balancing +decisions (for example, by avoiding disconnected backends). Configured sub-channels are fully setup to participate in the grpc data plane. Their behavior is specified by a set of grpc channel filters defined at their -construction. To customize this behavior, resolvers build -grpc_configured_subchannel_factory objects, which use the decorator pattern -to customize construction arguments for concrete grpc_configured_subchannel -instances. +construction. To customize this behavior, resolvers build grpc_subchannel_factory +objects, which use the decorator pattern to customize construction arguments for +concrete grpc_subchannel instances. diff --git a/src/core/client_config/configured_subchannel.h b/src/core/client_config/subchannel.h similarity index 74% rename from src/core/client_config/configured_subchannel.h rename to src/core/client_config/subchannel.h index e2e7cf8a1a1..56109a25700 100644 --- a/src/core/client_config/configured_subchannel.h +++ b/src/core/client_config/subchannel.h @@ -31,12 +31,12 @@ * */ -#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_H -#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_H +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H /** A (sub-)channel that knows how to connect to exactly one target address. Provides a target for load balancing. */ -typedef struct grpc_configured_subchannel grpc_configured_subchannel; +typedef struct grpc_subchannel grpc_subchannel; /** Connectivity state of a channel. TODO(ctiller): move to grpc.h when we implement the public @@ -54,19 +54,19 @@ typedef enum { GRPC_CHANNEL_FATAL_FAILURE } grpc_connectivity_state; -void grpc_configured_subchannel_ref(grpc_configured_subchannel *channel); -void grpc_configured_subchannel_unref(grpc_configured_subchannel *channel); +void grpc_subchannel_ref(grpc_subchannel *channel); +void grpc_subchannel_unref(grpc_subchannel *channel); /** poll the current connectivity state of a channel */ -grpc_connectivity_state grpc_configured_subchannel_check_connectivity( - grpc_configured_subchannel *channel); +grpc_connectivity_state grpc_subchannel_check_connectivity( + grpc_subchannel *channel); /** call notify when the connectivity state of a channel changes from *state. Updates *state with the new state of the channel */ -void grpc_configured_subchannel_notify_on_state_change( - grpc_configured_subchannel *channel, grpc_connectivity_state *state, - grpc_iomgr_closure *notify); +void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, + grpc_connectivity_state *state, + grpc_iomgr_closure *notify); /** continue processing of transport operation \a op */ -void grpc_configured_subchannel_continue_op(grpc_configured_subchannel *channel, - grpc_transport_op *op); +void grpc_subchannel_continue_op(grpc_subchannel *channel, + grpc_transport_op *op); -#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_H */ +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H */ diff --git a/src/core/client_config/configured_subchannel_factory.h b/src/core/client_config/subchannel_factory.h similarity index 63% rename from src/core/client_config/configured_subchannel_factory.h rename to src/core/client_config/subchannel_factory.h index 6bfc8e44363..aae47cc384f 100644 --- a/src/core/client_config/configured_subchannel_factory.h +++ b/src/core/client_config/subchannel_factory.h @@ -31,21 +31,19 @@ * */ -#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_FACTORY_H -#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_FACTORY_H +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H -typedef struct grpc_configured_subchannel_factory - grpc_configured_subchannel_factory; -typedef struct grpc_configured_subchannel_factory_vtable - grpc_configured_subchannel_factory_vtable; +typedef struct grpc_subchannel_factory grpc_subchannel_factory; +typedef struct grpc_subchannel_factory_vtable grpc_subchannel_factory_vtable; /** Constructor for new configured channels. Creating decorators around this type is encouraged to adapt behavior. */ -struct grpc_configured_subchannel_factory { - const grpc_configured_subchannel_factory_vtable *vtable; +struct grpc_subchannel_factory { + const grpc_subchannel_factory_vtable *vtable; }; -struct grpc_configured_subchannel_args { +struct grpc_subchannel_args { /* TODO(ctiller): consider making (parent, metadata_context) more opaque - these details are not needed at this level of API */ /** Parent channel element - passed from the master channel */ @@ -63,24 +61,19 @@ struct grpc_configured_subchannel_args { struct sockaddr *addr; }; -struct grpc_configured_subchannel_factory_vtable { - void (*ref)(grpc_configured_subchannel_factory *factory); - void (*unref)(grpc_configured_subchannel_factory *factory); - grpc_configured_subchannel *(*create_subchannel)( - grpc_configured_subchannel_factory *factory, - grpc_configured_subchannel_args *args); +struct grpc_subchannel_factory_vtable { + void (*ref)(grpc_subchannel_factory *factory); + void (*unref)(grpc_subchannel_factory *factory); + grpc_subchannel *(*create_subchannel)(grpc_subchannel_factory *factory, + grpc_subchannel_args *args); }; -void grpc_configured_subchannel_factory_ref( - grpc_configured_subchannel_factory *factory); -void grpc_configured_subchannel_factory_unref( - grpc_configured_subchannel_factory *factory); -/** Create a new grpc_configured_subchannel */ -void grpc_configured_subchannel_factory_create_subchannel( - grpc_configured_subchannel_factory *factory, - grpc_configured_subchannel_args *args); +void grpc_subchannel_factory_ref(grpc_subchannel_factory *factory); +void grpc_subchannel_factory_unref(grpc_subchannel_factory *factory); +/** Create a new grpc_subchannel */ +void grpc_subchannel_factory_create_subchannel(grpc_subchannel_factory *factory, + grpc_subchannel_args *args); -grpc_configured_subchannel_factory * -grpc_default_configured_subchannel_factory(); +grpc_subchannel_factory *grpc_default_subchannel_factory(); -#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONFIGURED_SUBCHANNEL_FACTORY_H */ +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H */ From d58b5b88479cd3b24c171104eb5494e0d0702e42 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 23 Jun 2015 12:30:00 -0700 Subject: [PATCH 026/124] Move parent subchannel construction args... ... into grpc_channel itself, to hide this complicated construction detail. --- src/core/client_config/subchannel.h | 2 ++ src/core/client_config/subchannel_factory.h | 9 +-------- src/core/surface/channel.h | 5 +++++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 56109a25700..8befc28d51e 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -60,11 +60,13 @@ void grpc_subchannel_unref(grpc_subchannel *channel); /** poll the current connectivity state of a channel */ grpc_connectivity_state grpc_subchannel_check_connectivity( grpc_subchannel *channel); + /** call notify when the connectivity state of a channel changes from *state. Updates *state with the new state of the channel */ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, grpc_connectivity_state *state, grpc_iomgr_closure *notify); + /** continue processing of transport operation \a op */ void grpc_subchannel_continue_op(grpc_subchannel *channel, grpc_transport_op *op); diff --git a/src/core/client_config/subchannel_factory.h b/src/core/client_config/subchannel_factory.h index aae47cc384f..854d2e29453 100644 --- a/src/core/client_config/subchannel_factory.h +++ b/src/core/client_config/subchannel_factory.h @@ -44,12 +44,6 @@ struct grpc_subchannel_factory { }; struct grpc_subchannel_args { - /* TODO(ctiller): consider making (parent, metadata_context) more opaque - - these details are not needed at this level of API */ - /** Parent channel element - passed from the master channel */ - grpc_channel_element *parent; - /** Metadata context for this channel - passed from the master channel */ - grpc_mdctx *metadata_context; /** Channel filters for this channel - wrapped factories will likely want to mutate this */ const grpc_channel_filter **filters; @@ -70,10 +64,9 @@ struct grpc_subchannel_factory_vtable { void grpc_subchannel_factory_ref(grpc_subchannel_factory *factory); void grpc_subchannel_factory_unref(grpc_subchannel_factory *factory); + /** Create a new grpc_subchannel */ void grpc_subchannel_factory_create_subchannel(grpc_subchannel_factory *factory, grpc_subchannel_args *args); -grpc_subchannel_factory *grpc_default_subchannel_factory(); - #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H */ diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h index 3c04676b43f..534eea33dc8 100644 --- a/src/core/surface/channel.h +++ b/src/core/surface/channel.h @@ -43,6 +43,11 @@ grpc_channel *grpc_channel_create_from_filters( /** Get a (borrowed) pointer to this channels underlying channel stack */ grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel); +/** Get a (borrowed) pointer to this channels subchannel factory (if it exists) + */ +grpc_subchannel_factory *grpc_channel_get_subchannel_factory( + grpc_channel *channel); + /** Get a (borrowed) pointer to the channel wide metadata context */ grpc_mdctx *grpc_channel_get_metadata_context(grpc_channel *channel); From af691804781f4e546c806b98ca8b05e2370e61f8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 23 Jun 2015 14:57:07 -0700 Subject: [PATCH 027/124] Flesh out things and make them compile --- BUILD | 20 +++++++++++ Makefile | 10 ++++++ build.json | 10 ++++++ gRPC.podspec | 4 +-- src/core/client_config/client_config.c | 34 +++++++++++++++++++ src/core/client_config/client_config.h | 2 ++ src/core/client_config/lb_policy.c | 34 +++++++++++++++++++ src/core/client_config/lb_policy.h | 8 ++--- src/core/client_config/resolver.c | 34 +++++++++++++++++++ src/core/client_config/resolver.h | 4 +++ src/core/client_config/subchannel.c | 34 +++++++++++++++++++ src/core/client_config/subchannel.h | 4 +++ src/core/client_config/subchannel_factory.c | 34 +++++++++++++++++++ src/core/client_config/subchannel_factory.h | 6 +++- src/core/surface/channel.h | 1 + tools/doxygen/Doxyfile.core.internal | 2 +- vsprojects/grpc/grpc.vcxproj | 15 ++++++++ vsprojects/grpc/grpc.vcxproj.filters | 33 ++++++++++++++++++ .../grpc_unsecure/grpc_unsecure.vcxproj | 15 ++++++++ .../grpc_unsecure.vcxproj.filters | 33 ++++++++++++++++++ 20 files changed, 329 insertions(+), 8 deletions(-) create mode 100644 src/core/client_config/client_config.c create mode 100644 src/core/client_config/lb_policy.c create mode 100644 src/core/client_config/resolver.c create mode 100644 src/core/client_config/subchannel.c create mode 100644 src/core/client_config/subchannel_factory.c diff --git a/BUILD b/BUILD index 3acee967e94..cc971a0d2ff 100644 --- a/BUILD +++ b/BUILD @@ -156,6 +156,11 @@ cc_library( "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.h", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.h", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -260,6 +265,11 @@ cc_library( "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", + "src/core/client_config/client_config.c", + "src/core/client_config/lb_policy.c", + "src/core/client_config/resolver.c", + "src/core/client_config/subchannel.c", + "src/core/client_config/subchannel_factory.c", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/debug/trace.c", @@ -381,6 +391,11 @@ cc_library( "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.h", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.h", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -463,6 +478,11 @@ cc_library( "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", + "src/core/client_config/client_config.c", + "src/core/client_config/lb_policy.c", + "src/core/client_config/resolver.c", + "src/core/client_config/subchannel.c", + "src/core/client_config/subchannel_factory.c", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/debug/trace.c", diff --git a/Makefile b/Makefile index 9db5e8b7d29..264f18e231e 100644 --- a/Makefile +++ b/Makefile @@ -3009,6 +3009,11 @@ LIBGRPC_SRC = \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ + src/core/client_config/client_config.c \ + src/core/client_config/lb_policy.c \ + src/core/client_config/resolver.c \ + src/core/client_config/subchannel.c \ + src/core/client_config/subchannel_factory.c \ src/core/compression/algorithm.c \ src/core/compression/message_compress.c \ src/core/debug/trace.c \ @@ -3255,6 +3260,11 @@ LIBGRPC_UNSECURE_SRC = \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ + src/core/client_config/client_config.c \ + src/core/client_config/lb_policy.c \ + src/core/client_config/resolver.c \ + src/core/client_config/subchannel.c \ + src/core/client_config/subchannel_factory.c \ src/core/compression/algorithm.c \ src/core/compression/message_compress.c \ src/core/debug/trace.c \ diff --git a/build.json b/build.json index 24f7edfec89..9c1472ca160 100644 --- a/build.json +++ b/build.json @@ -118,6 +118,11 @@ "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.h", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.h", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -200,6 +205,11 @@ "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", + "src/core/client_config/client_config.c", + "src/core/client_config/lb_policy.c", + "src/core/client_config/resolver.c", + "src/core/client_config/subchannel.c", + "src/core/client_config/subchannel_factory.c", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/debug/trace.c", diff --git a/gRPC.podspec b/gRPC.podspec index bd27055aec4..59665a01406 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -25,8 +25,8 @@ Pod::Spec.new do |s| # Core cross-platform gRPC library, written in C. s.subspec 'C-Core' do |cs| - cs.source_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/grpc_string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'include/grpc/support/alloc.h', 'include/grpc/support/atm.h', 'include/grpc/support/atm_gcc_atomic.h', 'include/grpc/support/atm_gcc_sync.h', 'include/grpc/support/atm_win32.h', 'include/grpc/support/cancellable_platform.h', 'include/grpc/support/cmdline.h', 'include/grpc/support/cpu.h', 'include/grpc/support/histogram.h', 'include/grpc/support/host_port.h', 'include/grpc/support/log.h', 'include/grpc/support/log_win32.h', 'include/grpc/support/port_platform.h', 'include/grpc/support/slice.h', 'include/grpc/support/slice_buffer.h', 'include/grpc/support/string_util.h', 'include/grpc/support/subprocess.h', 'include/grpc/support/sync.h', 'include/grpc/support/sync_generic.h', 'include/grpc/support/sync_posix.h', 'include/grpc/support/sync_win32.h', 'include/grpc/support/thd.h', 'include/grpc/support/grpc_time.h', 'include/grpc/support/tls.h', 'include/grpc/support/tls_gcc.h', 'include/grpc/support/tls_msvc.h', 'include/grpc/support/tls_pthread.h', 'include/grpc/support/useful.h', 'src/core/support/alloc.c', 'src/core/support/cancellable.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', 'src/core/support/cpu_linux.c', 'src/core/support/cpu_posix.c', 'src/core/support/cpu_windows.c', 'src/core/support/env_linux.c', 'src/core/support/env_posix.c', 'src/core/support/env_win32.c', 'src/core/support/file.c', 'src/core/support/file_posix.c', 'src/core/support/file_win32.c', 'src/core/support/histogram.c', 'src/core/support/host_port.c', 'src/core/support/log.c', 'src/core/support/log_android.c', 'src/core/support/log_linux.c', 'src/core/support/log_posix.c', 'src/core/support/log_win32.c', 'src/core/support/murmur_hash.c', 'src/core/support/slice.c', 'src/core/support/slice_buffer.c', 'src/core/support/string.c', 'src/core/support/string_posix.c', 'src/core/support/string_win32.c', 'src/core/support/subprocess_posix.c', 'src/core/support/sync.c', 'src/core/support/sync_posix.c', 'src/core/support/sync_win32.c', 'src/core/support/thd.c', 'src/core/support/thd_posix.c', 'src/core/support/thd_win32.c', 'src/core/support/time.c', 'src/core/support/time_posix.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', 'include/grpc/grpc_security.h', 'include/grpc/byte_buffer.h', 'include/grpc/byte_buffer_reader.h', 'include/grpc/compression.h', 'include/grpc/grpc.h', 'include/grpc/status.h', 'include/grpc/census.h', 'src/core/httpcli/format_request.c', 'src/core/httpcli/httpcli.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/httpcli/parser.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', 'src/core/security/credentials.c', 'src/core/security/credentials_metadata.c', 'src/core/security/credentials_posix.c', 'src/core/security/credentials_win32.c', 'src/core/security/google_default_credentials.c', 'src/core/security/json_token.c', 'src/core/security/secure_endpoint.c', 'src/core/security/secure_transport_setup.c', 'src/core/security/security_connector.c', 'src/core/security/security_context.c', 'src/core/security/server_auth_filter.c', 'src/core/security/server_secure_chttp2.c', 'src/core/surface/init_secure.c', 'src/core/surface/secure_channel_create.c', 'src/core/tsi/fake_transport_security.c', 'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/transport_security.c', 'src/core/census/grpc_context.c', 'src/core/channel/channel_args.c', 'src/core/channel/channel_stack.c', 'src/core/channel/child_channel.c', 'src/core/channel/client_channel.c', 'src/core/channel/client_setup.c', 'src/core/channel/connected_channel.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', 'src/core/compression/algorithm.c', 'src/core/compression/message_compress.c', 'src/core/debug/trace.c', 'src/core/iomgr/alarm.c', 'src/core/iomgr/alarm_heap.c', 'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_windows.c', 'src/core/iomgr/fd_posix.c', 'src/core/iomgr/iocp_windows.c', 'src/core/iomgr/iomgr.c', 'src/core/iomgr/iomgr_posix.c', 'src/core/iomgr/iomgr_windows.c', 'src/core/iomgr/pollset_kick_posix.c', 'src/core/iomgr/pollset_multipoller_with_epoll.c', 'src/core/iomgr/pollset_multipoller_with_poll_posix.c', 'src/core/iomgr/pollset_posix.c', 'src/core/iomgr/pollset_set_posix.c', 'src/core/iomgr/pollset_set_windows.c', 'src/core/iomgr/pollset_windows.c', 'src/core/iomgr/resolve_address_posix.c', 'src/core/iomgr/resolve_address_windows.c', 'src/core/iomgr/sockaddr_utils.c', 'src/core/iomgr/socket_utils_common_posix.c', 'src/core/iomgr/socket_utils_linux.c', 'src/core/iomgr/socket_utils_posix.c', 'src/core/iomgr/socket_windows.c', 'src/core/iomgr/tcp_client_posix.c', 'src/core/iomgr/tcp_client_windows.c', 'src/core/iomgr/tcp_posix.c', 'src/core/iomgr/tcp_server_posix.c', 'src/core/iomgr/tcp_server_windows.c', 'src/core/iomgr/tcp_windows.c', 'src/core/iomgr/time_averaged_stats.c', 'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_posix.c', 'src/core/json/json.c', 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', 'src/core/profiling/basic_timers.c', 'src/core/profiling/stap_timers.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', 'src/core/surface/byte_buffer_reader.c', 'src/core/surface/call.c', 'src/core/surface/call_details.c', 'src/core/surface/call_log_batch.c', 'src/core/surface/channel.c', 'src/core/surface/channel_create.c', 'src/core/surface/client.c', 'src/core/surface/completion_queue.c', 'src/core/surface/event_string.c', 'src/core/surface/init.c', 'src/core/surface/lame_client.c', 'src/core/surface/metadata_array.c', 'src/core/surface/server.c', 'src/core/surface/server_chttp2.c', 'src/core/surface/server_create.c', 'src/core/surface/surface_trace.c', 'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/bin_encoder.c', 'src/core/transport/chttp2/frame_data.c', 'src/core/transport/chttp2/frame_goaway.c', 'src/core/transport/chttp2/frame_ping.c', 'src/core/transport/chttp2/frame_rst_stream.c', 'src/core/transport/chttp2/frame_settings.c', 'src/core/transport/chttp2/frame_window_update.c', 'src/core/transport/chttp2/hpack_parser.c', 'src/core/transport/chttp2/hpack_table.c', 'src/core/transport/chttp2/huffsyms.c', 'src/core/transport/chttp2/status_conversion.c', 'src/core/transport/chttp2/stream_encoder.c', 'src/core/transport/chttp2/stream_map.c', 'src/core/transport/chttp2/timeout_encoding.c', 'src/core/transport/chttp2/varint.c', 'src/core/transport/chttp2_transport.c', 'src/core/transport/metadata.c', 'src/core/transport/stream_op.c', 'src/core/transport/transport.c', 'src/core/transport/transport_op_string.c', 'src/core/census/context.c', 'src/core/census/initialize.c', - cs.private_header_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', + cs.source_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/grpc_string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'include/grpc/support/alloc.h', 'include/grpc/support/atm.h', 'include/grpc/support/atm_gcc_atomic.h', 'include/grpc/support/atm_gcc_sync.h', 'include/grpc/support/atm_win32.h', 'include/grpc/support/cancellable_platform.h', 'include/grpc/support/cmdline.h', 'include/grpc/support/cpu.h', 'include/grpc/support/histogram.h', 'include/grpc/support/host_port.h', 'include/grpc/support/log.h', 'include/grpc/support/log_win32.h', 'include/grpc/support/port_platform.h', 'include/grpc/support/slice.h', 'include/grpc/support/slice_buffer.h', 'include/grpc/support/string_util.h', 'include/grpc/support/subprocess.h', 'include/grpc/support/sync.h', 'include/grpc/support/sync_generic.h', 'include/grpc/support/sync_posix.h', 'include/grpc/support/sync_win32.h', 'include/grpc/support/thd.h', 'include/grpc/support/grpc_time.h', 'include/grpc/support/tls.h', 'include/grpc/support/tls_gcc.h', 'include/grpc/support/tls_msvc.h', 'include/grpc/support/tls_pthread.h', 'include/grpc/support/useful.h', 'src/core/support/alloc.c', 'src/core/support/cancellable.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', 'src/core/support/cpu_linux.c', 'src/core/support/cpu_posix.c', 'src/core/support/cpu_windows.c', 'src/core/support/env_linux.c', 'src/core/support/env_posix.c', 'src/core/support/env_win32.c', 'src/core/support/file.c', 'src/core/support/file_posix.c', 'src/core/support/file_win32.c', 'src/core/support/histogram.c', 'src/core/support/host_port.c', 'src/core/support/log.c', 'src/core/support/log_android.c', 'src/core/support/log_linux.c', 'src/core/support/log_posix.c', 'src/core/support/log_win32.c', 'src/core/support/murmur_hash.c', 'src/core/support/slice.c', 'src/core/support/slice_buffer.c', 'src/core/support/string.c', 'src/core/support/string_posix.c', 'src/core/support/string_win32.c', 'src/core/support/subprocess_posix.c', 'src/core/support/sync.c', 'src/core/support/sync_posix.c', 'src/core/support/sync_win32.c', 'src/core/support/thd.c', 'src/core/support/thd_posix.c', 'src/core/support/thd_win32.c', 'src/core/support/time.c', 'src/core/support/time_posix.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', 'include/grpc/grpc_security.h', 'include/grpc/byte_buffer.h', 'include/grpc/byte_buffer_reader.h', 'include/grpc/compression.h', 'include/grpc/grpc.h', 'include/grpc/status.h', 'include/grpc/census.h', 'src/core/httpcli/format_request.c', 'src/core/httpcli/httpcli.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/httpcli/parser.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', 'src/core/security/credentials.c', 'src/core/security/credentials_metadata.c', 'src/core/security/credentials_posix.c', 'src/core/security/credentials_win32.c', 'src/core/security/google_default_credentials.c', 'src/core/security/json_token.c', 'src/core/security/secure_endpoint.c', 'src/core/security/secure_transport_setup.c', 'src/core/security/security_connector.c', 'src/core/security/security_context.c', 'src/core/security/server_auth_filter.c', 'src/core/security/server_secure_chttp2.c', 'src/core/surface/init_secure.c', 'src/core/surface/secure_channel_create.c', 'src/core/tsi/fake_transport_security.c', 'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/transport_security.c', 'src/core/census/grpc_context.c', 'src/core/channel/channel_args.c', 'src/core/channel/channel_stack.c', 'src/core/channel/child_channel.c', 'src/core/channel/client_channel.c', 'src/core/channel/client_setup.c', 'src/core/channel/connected_channel.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', 'src/core/client_config/client_config.c', 'src/core/client_config/lb_policy.c', 'src/core/client_config/resolver.c', 'src/core/client_config/subchannel.c', 'src/core/client_config/subchannel_factory.c', 'src/core/compression/algorithm.c', 'src/core/compression/message_compress.c', 'src/core/debug/trace.c', 'src/core/iomgr/alarm.c', 'src/core/iomgr/alarm_heap.c', 'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_windows.c', 'src/core/iomgr/fd_posix.c', 'src/core/iomgr/iocp_windows.c', 'src/core/iomgr/iomgr.c', 'src/core/iomgr/iomgr_posix.c', 'src/core/iomgr/iomgr_windows.c', 'src/core/iomgr/pollset_kick_posix.c', 'src/core/iomgr/pollset_multipoller_with_epoll.c', 'src/core/iomgr/pollset_multipoller_with_poll_posix.c', 'src/core/iomgr/pollset_posix.c', 'src/core/iomgr/pollset_set_posix.c', 'src/core/iomgr/pollset_set_windows.c', 'src/core/iomgr/pollset_windows.c', 'src/core/iomgr/resolve_address_posix.c', 'src/core/iomgr/resolve_address_windows.c', 'src/core/iomgr/sockaddr_utils.c', 'src/core/iomgr/socket_utils_common_posix.c', 'src/core/iomgr/socket_utils_linux.c', 'src/core/iomgr/socket_utils_posix.c', 'src/core/iomgr/socket_windows.c', 'src/core/iomgr/tcp_client_posix.c', 'src/core/iomgr/tcp_client_windows.c', 'src/core/iomgr/tcp_posix.c', 'src/core/iomgr/tcp_server_posix.c', 'src/core/iomgr/tcp_server_windows.c', 'src/core/iomgr/tcp_windows.c', 'src/core/iomgr/time_averaged_stats.c', 'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_posix.c', 'src/core/json/json.c', 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', 'src/core/profiling/basic_timers.c', 'src/core/profiling/stap_timers.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', 'src/core/surface/byte_buffer_reader.c', 'src/core/surface/call.c', 'src/core/surface/call_details.c', 'src/core/surface/call_log_batch.c', 'src/core/surface/channel.c', 'src/core/surface/channel_create.c', 'src/core/surface/client.c', 'src/core/surface/completion_queue.c', 'src/core/surface/event_string.c', 'src/core/surface/init.c', 'src/core/surface/lame_client.c', 'src/core/surface/metadata_array.c', 'src/core/surface/server.c', 'src/core/surface/server_chttp2.c', 'src/core/surface/server_create.c', 'src/core/surface/surface_trace.c', 'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/bin_encoder.c', 'src/core/transport/chttp2/frame_data.c', 'src/core/transport/chttp2/frame_goaway.c', 'src/core/transport/chttp2/frame_ping.c', 'src/core/transport/chttp2/frame_rst_stream.c', 'src/core/transport/chttp2/frame_settings.c', 'src/core/transport/chttp2/frame_window_update.c', 'src/core/transport/chttp2/hpack_parser.c', 'src/core/transport/chttp2/hpack_table.c', 'src/core/transport/chttp2/huffsyms.c', 'src/core/transport/chttp2/status_conversion.c', 'src/core/transport/chttp2/stream_encoder.c', 'src/core/transport/chttp2/stream_map.c', 'src/core/transport/chttp2/timeout_encoding.c', 'src/core/transport/chttp2/varint.c', 'src/core/transport/chttp2_transport.c', 'src/core/transport/metadata.c', 'src/core/transport/stream_op.c', 'src/core/transport/transport.c', 'src/core/transport/transport_op_string.c', 'src/core/census/context.c', 'src/core/census/initialize.c', + cs.private_header_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', cs.header_mappings_dir = '.' # The core library includes its headers as either "src/core/..." or "grpc/...", meaning we have # to tell XCode to look for headers under the "include" subdirectory too. diff --git a/src/core/client_config/client_config.c b/src/core/client_config/client_config.c new file mode 100644 index 00000000000..f462e54b4eb --- /dev/null +++ b/src/core/client_config/client_config.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/client_config.h" diff --git a/src/core/client_config/client_config.h b/src/core/client_config/client_config.h index 7974e24bc3c..44d281f6715 100644 --- a/src/core/client_config/client_config.h +++ b/src/core/client_config/client_config.h @@ -34,6 +34,8 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H +#include "src/core/client_config/lb_policy.h" + /** Total configuration for a client. Provided, and updated, by grpc_resolver */ typedef struct grpc_client_config grpc_client_config; diff --git a/src/core/client_config/lb_policy.c b/src/core/client_config/lb_policy.c new file mode 100644 index 00000000000..d8be4650cd9 --- /dev/null +++ b/src/core/client_config/lb_policy.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/lb_policy.h" diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 5cf81990472..ae95c3367b9 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -34,7 +34,7 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H -#include "src/core/client_config/configured_channel.h" +#include "src/core/client_config/subchannel.h" /** A load balancing policy: specified by a vtable and a struct (which is expected to be extended to contain some parameters) */ @@ -42,7 +42,7 @@ typedef struct grpc_lb_policy grpc_lb_policy; typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable; typedef void (*grpc_lb_completion)(void *cb_arg, - grpc_configured_channel *configured_channel, + grpc_subchannel *subchannel, grpc_status_code status, const char *errmsg); struct grpc_lb_policy_vtable { @@ -54,7 +54,7 @@ struct grpc_lb_policy_vtable { /** implement grpc_lb_policy_pick */ void (*pick)(grpc_lb_policy *policy, grpc_pollset *pollset, grpc_metadata_batch *initial_metadata, - grpc_configured_channel **target, + grpc_subchannel **target, grpc_iomgr_closure *on_complete); }; @@ -67,7 +67,7 @@ void grpc_lb_policy_shutdown(grpc_lb_policy *policy); Picking can be asynchronous. Any IO should be done under \a pollset. */ void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset, grpc_metadata_batch *initial_metadata, - grpc_configured_channel **target, + grpc_subchannel **target, grpc_iomgr_closure *on_complete); #endif /* GRPC_INTERNAL_CORE_CONFIG_LB_POLICY_H */ diff --git a/src/core/client_config/resolver.c b/src/core/client_config/resolver.c new file mode 100644 index 00000000000..730ec317492 --- /dev/null +++ b/src/core/client_config/resolver.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/resolver.h" diff --git a/src/core/client_config/resolver.h b/src/core/client_config/resolver.h index 13672fb3eeb..7ff955ec6e6 100644 --- a/src/core/client_config/resolver.h +++ b/src/core/client_config/resolver.h @@ -34,6 +34,10 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_H +#include "src/core/client_config/client_config.h" +#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/sockaddr.h" + typedef struct grpc_resolver grpc_resolver; typedef struct grpc_resolver_vtable grpc_resolver_vtable; diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c new file mode 100644 index 00000000000..dfaa4f6405f --- /dev/null +++ b/src/core/client_config/subchannel.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/subchannel.h" diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 8befc28d51e..a10a75d6ac8 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -34,6 +34,10 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H +#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/sockaddr.h" +#include "src/core/transport/transport.h" + /** A (sub-)channel that knows how to connect to exactly one target address. Provides a target for load balancing. */ typedef struct grpc_subchannel grpc_subchannel; diff --git a/src/core/client_config/subchannel_factory.c b/src/core/client_config/subchannel_factory.c new file mode 100644 index 00000000000..06e8a4bdaf6 --- /dev/null +++ b/src/core/client_config/subchannel_factory.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/subchannel_factory.h" diff --git a/src/core/client_config/subchannel_factory.h b/src/core/client_config/subchannel_factory.h index 854d2e29453..26fa3297974 100644 --- a/src/core/client_config/subchannel_factory.h +++ b/src/core/client_config/subchannel_factory.h @@ -34,8 +34,12 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H +#include "src/core/channel/channel_stack.h" +#include "src/core/client_config/subchannel.h" + typedef struct grpc_subchannel_factory grpc_subchannel_factory; typedef struct grpc_subchannel_factory_vtable grpc_subchannel_factory_vtable; +typedef struct grpc_subchannel_args grpc_subchannel_args; /** Constructor for new configured channels. Creating decorators around this type is encouraged to adapt behavior. */ @@ -51,7 +55,7 @@ struct grpc_subchannel_args { size_t filter_count; /** Channel arguments to be supplied to the newly created channel */ const grpc_channel_args *args; - + /** Address to connect to */ struct sockaddr *addr; }; diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h index 534eea33dc8..58fa91e9767 100644 --- a/src/core/surface/channel.h +++ b/src/core/surface/channel.h @@ -35,6 +35,7 @@ #define GRPC_INTERNAL_CORE_SURFACE_CHANNEL_H #include "src/core/channel/channel_stack.h" +#include "src/core/client_config/subchannel_factory.h" grpc_channel *grpc_channel_create_from_filters( const grpc_channel_filter **filters, size_t count, diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index c71676568e5..9592824a5e6 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -760,7 +760,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = include/grpc/grpc_security.h include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h include/grpc/grpc.h include/grpc/status.h include/grpc/census.h src/core/httpcli/format_request.h src/core/httpcli/httpcli.h src/core/httpcli/httpcli_security_connector.h src/core/httpcli/parser.h src/core/security/auth_filters.h src/core/security/base64.h src/core/security/credentials.h src/core/security/json_token.h src/core/security/secure_endpoint.h src/core/security/secure_transport_setup.h src/core/security/security_connector.h src/core/security/security_context.h src/core/tsi/fake_transport_security.h src/core/tsi/ssl_transport_security.h src/core/tsi/transport_security.h src/core/tsi/transport_security_interface.h src/core/census/grpc_context.h src/core/channel/census_filter.h src/core/channel/channel_args.h src/core/channel/channel_stack.h src/core/channel/child_channel.h src/core/channel/client_channel.h src/core/channel/client_setup.h src/core/channel/connected_channel.h src/core/channel/context.h src/core/channel/http_client_filter.h src/core/channel/http_server_filter.h src/core/channel/noop_filter.h src/core/compression/message_compress.h src/core/debug/trace.h src/core/iomgr/alarm.h src/core/iomgr/alarm_heap.h src/core/iomgr/alarm_internal.h src/core/iomgr/endpoint.h src/core/iomgr/endpoint_pair.h src/core/iomgr/fd_posix.h src/core/iomgr/iocp_windows.h src/core/iomgr/iomgr.h src/core/iomgr/iomgr_internal.h src/core/iomgr/iomgr_posix.h src/core/iomgr/pollset.h src/core/iomgr/pollset_kick_posix.h src/core/iomgr/pollset_posix.h src/core/iomgr/pollset_set_posix.h src/core/iomgr/pollset_set_windows.h src/core/iomgr/pollset_windows.h src/core/iomgr/resolve_address.h src/core/iomgr/sockaddr.h src/core/iomgr/sockaddr_posix.h src/core/iomgr/sockaddr_utils.h src/core/iomgr/sockaddr_win32.h src/core/iomgr/socket_utils_posix.h src/core/iomgr/socket_windows.h src/core/iomgr/tcp_client.h src/core/iomgr/tcp_posix.h src/core/iomgr/tcp_server.h src/core/iomgr/tcp_windows.h src/core/iomgr/time_averaged_stats.h src/core/iomgr/wakeup_fd_pipe.h src/core/iomgr/wakeup_fd_posix.h src/core/json/json.h src/core/json/json_common.h src/core/json/json_reader.h src/core/json/json_writer.h src/core/profiling/timers.h src/core/profiling/timers_preciseclock.h src/core/surface/byte_buffer_queue.h src/core/surface/call.h src/core/surface/channel.h src/core/surface/client.h src/core/surface/completion_queue.h src/core/surface/event_string.h src/core/surface/init.h src/core/surface/server.h src/core/surface/surface_trace.h src/core/transport/chttp2/alpn.h src/core/transport/chttp2/bin_encoder.h src/core/transport/chttp2/frame.h src/core/transport/chttp2/frame_data.h src/core/transport/chttp2/frame_goaway.h src/core/transport/chttp2/frame_ping.h src/core/transport/chttp2/frame_rst_stream.h src/core/transport/chttp2/frame_settings.h src/core/transport/chttp2/frame_window_update.h src/core/transport/chttp2/hpack_parser.h src/core/transport/chttp2/hpack_table.h src/core/transport/chttp2/http2_errors.h src/core/transport/chttp2/huffsyms.h src/core/transport/chttp2/status_conversion.h src/core/transport/chttp2/stream_encoder.h src/core/transport/chttp2/stream_map.h src/core/transport/chttp2/timeout_encoding.h src/core/transport/chttp2/varint.h src/core/transport/chttp2_transport.h src/core/transport/metadata.h src/core/transport/stream_op.h src/core/transport/transport.h src/core/transport/transport_impl.h src/core/census/context.h src/core/httpcli/format_request.c src/core/httpcli/httpcli.c src/core/httpcli/httpcli_security_connector.c src/core/httpcli/parser.c src/core/security/base64.c src/core/security/client_auth_filter.c src/core/security/credentials.c src/core/security/credentials_metadata.c src/core/security/credentials_posix.c src/core/security/credentials_win32.c src/core/security/google_default_credentials.c src/core/security/json_token.c src/core/security/secure_endpoint.c src/core/security/secure_transport_setup.c src/core/security/security_connector.c src/core/security/security_context.c src/core/security/server_auth_filter.c src/core/security/server_secure_chttp2.c src/core/surface/init_secure.c src/core/surface/secure_channel_create.c src/core/tsi/fake_transport_security.c src/core/tsi/ssl_transport_security.c src/core/tsi/transport_security.c src/core/census/grpc_context.c src/core/channel/channel_args.c src/core/channel/channel_stack.c src/core/channel/child_channel.c src/core/channel/client_channel.c src/core/channel/client_setup.c src/core/channel/connected_channel.c src/core/channel/http_client_filter.c src/core/channel/http_server_filter.c src/core/channel/noop_filter.c src/core/compression/algorithm.c src/core/compression/message_compress.c src/core/debug/trace.c src/core/iomgr/alarm.c src/core/iomgr/alarm_heap.c src/core/iomgr/endpoint.c src/core/iomgr/endpoint_pair_posix.c src/core/iomgr/endpoint_pair_windows.c src/core/iomgr/fd_posix.c src/core/iomgr/iocp_windows.c src/core/iomgr/iomgr.c src/core/iomgr/iomgr_posix.c src/core/iomgr/iomgr_windows.c src/core/iomgr/pollset_kick_posix.c src/core/iomgr/pollset_multipoller_with_epoll.c src/core/iomgr/pollset_multipoller_with_poll_posix.c src/core/iomgr/pollset_posix.c src/core/iomgr/pollset_set_posix.c src/core/iomgr/pollset_set_windows.c src/core/iomgr/pollset_windows.c src/core/iomgr/resolve_address_posix.c src/core/iomgr/resolve_address_windows.c src/core/iomgr/sockaddr_utils.c src/core/iomgr/socket_utils_common_posix.c src/core/iomgr/socket_utils_linux.c src/core/iomgr/socket_utils_posix.c src/core/iomgr/socket_windows.c src/core/iomgr/tcp_client_posix.c src/core/iomgr/tcp_client_windows.c src/core/iomgr/tcp_posix.c src/core/iomgr/tcp_server_posix.c src/core/iomgr/tcp_server_windows.c src/core/iomgr/tcp_windows.c src/core/iomgr/time_averaged_stats.c src/core/iomgr/wakeup_fd_eventfd.c src/core/iomgr/wakeup_fd_nospecial.c src/core/iomgr/wakeup_fd_pipe.c src/core/iomgr/wakeup_fd_posix.c src/core/json/json.c src/core/json/json_reader.c src/core/json/json_string.c src/core/json/json_writer.c src/core/profiling/basic_timers.c src/core/profiling/stap_timers.c src/core/surface/byte_buffer.c src/core/surface/byte_buffer_queue.c src/core/surface/byte_buffer_reader.c src/core/surface/call.c src/core/surface/call_details.c src/core/surface/call_log_batch.c src/core/surface/channel.c src/core/surface/channel_create.c src/core/surface/client.c src/core/surface/completion_queue.c src/core/surface/event_string.c src/core/surface/init.c src/core/surface/lame_client.c src/core/surface/metadata_array.c src/core/surface/server.c src/core/surface/server_chttp2.c src/core/surface/server_create.c src/core/surface/surface_trace.c src/core/transport/chttp2/alpn.c src/core/transport/chttp2/bin_encoder.c src/core/transport/chttp2/frame_data.c src/core/transport/chttp2/frame_goaway.c src/core/transport/chttp2/frame_ping.c src/core/transport/chttp2/frame_rst_stream.c src/core/transport/chttp2/frame_settings.c src/core/transport/chttp2/frame_window_update.c src/core/transport/chttp2/hpack_parser.c src/core/transport/chttp2/hpack_table.c src/core/transport/chttp2/huffsyms.c src/core/transport/chttp2/status_conversion.c src/core/transport/chttp2/stream_encoder.c src/core/transport/chttp2/stream_map.c src/core/transport/chttp2/timeout_encoding.c src/core/transport/chttp2/varint.c src/core/transport/chttp2_transport.c src/core/transport/metadata.c src/core/transport/stream_op.c src/core/transport/transport.c src/core/transport/transport_op_string.c src/core/census/context.c src/core/census/initialize.c include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_win32.h include/grpc/support/cancellable_platform.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/histogram.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_win32.h include/grpc/support/port_platform.h include/grpc/support/slice.h include/grpc/support/slice_buffer.h include/grpc/support/string_util.h include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h include/grpc/support/sync_win32.h include/grpc/support/thd.h include/grpc/support/time.h include/grpc/support/tls.h include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h include/grpc/support/useful.h src/core/support/env.h src/core/support/file.h src/core/support/murmur_hash.h src/core/support/string.h src/core/support/string_win32.h src/core/support/thd_internal.h src/core/support/alloc.c src/core/support/cancellable.c src/core/support/cmdline.c src/core/support/cpu_iphone.c src/core/support/cpu_linux.c src/core/support/cpu_posix.c src/core/support/cpu_windows.c src/core/support/env_linux.c src/core/support/env_posix.c src/core/support/env_win32.c src/core/support/file.c src/core/support/file_posix.c src/core/support/file_win32.c src/core/support/histogram.c src/core/support/host_port.c src/core/support/log.c src/core/support/log_android.c src/core/support/log_linux.c src/core/support/log_posix.c src/core/support/log_win32.c src/core/support/murmur_hash.c src/core/support/slice.c src/core/support/slice_buffer.c src/core/support/string.c src/core/support/string_posix.c src/core/support/string_win32.c src/core/support/subprocess_posix.c src/core/support/sync.c src/core/support/sync_posix.c src/core/support/sync_win32.c src/core/support/thd.c src/core/support/thd_posix.c src/core/support/thd_win32.c src/core/support/time.c src/core/support/time_posix.c src/core/support/time_win32.c src/core/support/tls_pthread.c +INPUT = include/grpc/grpc_security.h include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h include/grpc/grpc.h include/grpc/status.h include/grpc/census.h src/core/httpcli/format_request.h src/core/httpcli/httpcli.h src/core/httpcli/httpcli_security_connector.h src/core/httpcli/parser.h src/core/security/auth_filters.h src/core/security/base64.h src/core/security/credentials.h src/core/security/json_token.h src/core/security/secure_endpoint.h src/core/security/secure_transport_setup.h src/core/security/security_connector.h src/core/security/security_context.h src/core/tsi/fake_transport_security.h src/core/tsi/ssl_transport_security.h src/core/tsi/transport_security.h src/core/tsi/transport_security_interface.h src/core/census/grpc_context.h src/core/channel/census_filter.h src/core/channel/channel_args.h src/core/channel/channel_stack.h src/core/channel/child_channel.h src/core/channel/client_channel.h src/core/channel/client_setup.h src/core/channel/connected_channel.h src/core/channel/context.h src/core/channel/http_client_filter.h src/core/channel/http_server_filter.h src/core/channel/noop_filter.h src/core/client_config/client_config.h src/core/client_config/lb_policy.h src/core/client_config/resolver.h src/core/client_config/subchannel.h src/core/client_config/subchannel_factory.h src/core/compression/message_compress.h src/core/debug/trace.h src/core/iomgr/alarm.h src/core/iomgr/alarm_heap.h src/core/iomgr/alarm_internal.h src/core/iomgr/endpoint.h src/core/iomgr/endpoint_pair.h src/core/iomgr/fd_posix.h src/core/iomgr/iocp_windows.h src/core/iomgr/iomgr.h src/core/iomgr/iomgr_internal.h src/core/iomgr/iomgr_posix.h src/core/iomgr/pollset.h src/core/iomgr/pollset_kick_posix.h src/core/iomgr/pollset_posix.h src/core/iomgr/pollset_set_posix.h src/core/iomgr/pollset_set_windows.h src/core/iomgr/pollset_windows.h src/core/iomgr/resolve_address.h src/core/iomgr/sockaddr.h src/core/iomgr/sockaddr_posix.h src/core/iomgr/sockaddr_utils.h src/core/iomgr/sockaddr_win32.h src/core/iomgr/socket_utils_posix.h src/core/iomgr/socket_windows.h src/core/iomgr/tcp_client.h src/core/iomgr/tcp_posix.h src/core/iomgr/tcp_server.h src/core/iomgr/tcp_windows.h src/core/iomgr/time_averaged_stats.h src/core/iomgr/wakeup_fd_pipe.h src/core/iomgr/wakeup_fd_posix.h src/core/json/json.h src/core/json/json_common.h src/core/json/json_reader.h src/core/json/json_writer.h src/core/profiling/timers.h src/core/profiling/timers_preciseclock.h src/core/surface/byte_buffer_queue.h src/core/surface/call.h src/core/surface/channel.h src/core/surface/client.h src/core/surface/completion_queue.h src/core/surface/event_string.h src/core/surface/init.h src/core/surface/server.h src/core/surface/surface_trace.h src/core/transport/chttp2/alpn.h src/core/transport/chttp2/bin_encoder.h src/core/transport/chttp2/frame.h src/core/transport/chttp2/frame_data.h src/core/transport/chttp2/frame_goaway.h src/core/transport/chttp2/frame_ping.h src/core/transport/chttp2/frame_rst_stream.h src/core/transport/chttp2/frame_settings.h src/core/transport/chttp2/frame_window_update.h src/core/transport/chttp2/hpack_parser.h src/core/transport/chttp2/hpack_table.h src/core/transport/chttp2/http2_errors.h src/core/transport/chttp2/huffsyms.h src/core/transport/chttp2/status_conversion.h src/core/transport/chttp2/stream_encoder.h src/core/transport/chttp2/stream_map.h src/core/transport/chttp2/timeout_encoding.h src/core/transport/chttp2/varint.h src/core/transport/chttp2_transport.h src/core/transport/metadata.h src/core/transport/stream_op.h src/core/transport/transport.h src/core/transport/transport_impl.h src/core/census/context.h src/core/httpcli/format_request.c src/core/httpcli/httpcli.c src/core/httpcli/httpcli_security_connector.c src/core/httpcli/parser.c src/core/security/base64.c src/core/security/client_auth_filter.c src/core/security/credentials.c src/core/security/credentials_metadata.c src/core/security/credentials_posix.c src/core/security/credentials_win32.c src/core/security/google_default_credentials.c src/core/security/json_token.c src/core/security/secure_endpoint.c src/core/security/secure_transport_setup.c src/core/security/security_connector.c src/core/security/security_context.c src/core/security/server_auth_filter.c src/core/security/server_secure_chttp2.c src/core/surface/init_secure.c src/core/surface/secure_channel_create.c src/core/tsi/fake_transport_security.c src/core/tsi/ssl_transport_security.c src/core/tsi/transport_security.c src/core/census/grpc_context.c src/core/channel/channel_args.c src/core/channel/channel_stack.c src/core/channel/child_channel.c src/core/channel/client_channel.c src/core/channel/client_setup.c src/core/channel/connected_channel.c src/core/channel/http_client_filter.c src/core/channel/http_server_filter.c src/core/channel/noop_filter.c src/core/client_config/client_config.c src/core/client_config/lb_policy.c src/core/client_config/resolver.c src/core/client_config/subchannel.c src/core/client_config/subchannel_factory.c src/core/compression/algorithm.c src/core/compression/message_compress.c src/core/debug/trace.c src/core/iomgr/alarm.c src/core/iomgr/alarm_heap.c src/core/iomgr/endpoint.c src/core/iomgr/endpoint_pair_posix.c src/core/iomgr/endpoint_pair_windows.c src/core/iomgr/fd_posix.c src/core/iomgr/iocp_windows.c src/core/iomgr/iomgr.c src/core/iomgr/iomgr_posix.c src/core/iomgr/iomgr_windows.c src/core/iomgr/pollset_kick_posix.c src/core/iomgr/pollset_multipoller_with_epoll.c src/core/iomgr/pollset_multipoller_with_poll_posix.c src/core/iomgr/pollset_posix.c src/core/iomgr/pollset_set_posix.c src/core/iomgr/pollset_set_windows.c src/core/iomgr/pollset_windows.c src/core/iomgr/resolve_address_posix.c src/core/iomgr/resolve_address_windows.c src/core/iomgr/sockaddr_utils.c src/core/iomgr/socket_utils_common_posix.c src/core/iomgr/socket_utils_linux.c src/core/iomgr/socket_utils_posix.c src/core/iomgr/socket_windows.c src/core/iomgr/tcp_client_posix.c src/core/iomgr/tcp_client_windows.c src/core/iomgr/tcp_posix.c src/core/iomgr/tcp_server_posix.c src/core/iomgr/tcp_server_windows.c src/core/iomgr/tcp_windows.c src/core/iomgr/time_averaged_stats.c src/core/iomgr/wakeup_fd_eventfd.c src/core/iomgr/wakeup_fd_nospecial.c src/core/iomgr/wakeup_fd_pipe.c src/core/iomgr/wakeup_fd_posix.c src/core/json/json.c src/core/json/json_reader.c src/core/json/json_string.c src/core/json/json_writer.c src/core/profiling/basic_timers.c src/core/profiling/stap_timers.c src/core/surface/byte_buffer.c src/core/surface/byte_buffer_queue.c src/core/surface/byte_buffer_reader.c src/core/surface/call.c src/core/surface/call_details.c src/core/surface/call_log_batch.c src/core/surface/channel.c src/core/surface/channel_create.c src/core/surface/client.c src/core/surface/completion_queue.c src/core/surface/event_string.c src/core/surface/init.c src/core/surface/lame_client.c src/core/surface/metadata_array.c src/core/surface/server.c src/core/surface/server_chttp2.c src/core/surface/server_create.c src/core/surface/surface_trace.c src/core/transport/chttp2/alpn.c src/core/transport/chttp2/bin_encoder.c src/core/transport/chttp2/frame_data.c src/core/transport/chttp2/frame_goaway.c src/core/transport/chttp2/frame_ping.c src/core/transport/chttp2/frame_rst_stream.c src/core/transport/chttp2/frame_settings.c src/core/transport/chttp2/frame_window_update.c src/core/transport/chttp2/hpack_parser.c src/core/transport/chttp2/hpack_table.c src/core/transport/chttp2/huffsyms.c src/core/transport/chttp2/status_conversion.c src/core/transport/chttp2/stream_encoder.c src/core/transport/chttp2/stream_map.c src/core/transport/chttp2/timeout_encoding.c src/core/transport/chttp2/varint.c src/core/transport/chttp2_transport.c src/core/transport/metadata.c src/core/transport/stream_op.c src/core/transport/transport.c src/core/transport/transport_op_string.c src/core/census/context.c src/core/census/initialize.c include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_win32.h include/grpc/support/cancellable_platform.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/histogram.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_win32.h include/grpc/support/port_platform.h include/grpc/support/slice.h include/grpc/support/slice_buffer.h include/grpc/support/string_util.h include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h include/grpc/support/sync_win32.h include/grpc/support/thd.h include/grpc/support/time.h include/grpc/support/tls.h include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h include/grpc/support/useful.h src/core/support/env.h src/core/support/file.h src/core/support/murmur_hash.h src/core/support/string.h src/core/support/string_win32.h src/core/support/thd_internal.h src/core/support/alloc.c src/core/support/cancellable.c src/core/support/cmdline.c src/core/support/cpu_iphone.c src/core/support/cpu_linux.c src/core/support/cpu_posix.c src/core/support/cpu_windows.c src/core/support/env_linux.c src/core/support/env_posix.c src/core/support/env_win32.c src/core/support/file.c src/core/support/file_posix.c src/core/support/file_win32.c src/core/support/histogram.c src/core/support/host_port.c src/core/support/log.c src/core/support/log_android.c src/core/support/log_linux.c src/core/support/log_posix.c src/core/support/log_win32.c src/core/support/murmur_hash.c src/core/support/slice.c src/core/support/slice_buffer.c src/core/support/string.c src/core/support/string_posix.c src/core/support/string_win32.c src/core/support/subprocess_posix.c src/core/support/sync.c src/core/support/sync_posix.c src/core/support/sync_win32.c src/core/support/thd.c src/core/support/thd_posix.c src/core/support/thd_win32.c src/core/support/time.c src/core/support/time_posix.c src/core/support/time_win32.c src/core/support/tls_pthread.c # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 37ebfed6ed9..d45733168c2 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -184,6 +184,11 @@ + + + + + @@ -323,6 +328,16 @@ + + + + + + + + + + diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index 789febbaf8f..a40161aadf3 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -100,6 +100,21 @@ src\core\channel + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + src\core\compression @@ -464,6 +479,21 @@ src\core\channel + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + src\core\compression @@ -698,6 +728,9 @@ {d897b6c3-c555-234e-a589-b4f008063615} + + {e71e6928-b1e3-0616-0961-1505370458ab} + {263cb913-dfe6-42a4-096b-cac231f76305} diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index d73ce725423..070b6d02870 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -166,6 +166,11 @@ + + + + + @@ -261,6 +266,16 @@ + + + + + + + + + + diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index ee283cb9ff3..5044bdc8176 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -34,6 +34,21 @@ src\core\channel + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + src\core\compression @@ -347,6 +362,21 @@ src\core\channel + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + + + src\core\client_config + src\core\compression @@ -581,6 +611,9 @@ {cc102c4b-66ff-cf4c-2288-d76327e1a183} + + {02bd7340-02ee-4337-ffa5-0b6ecc7cf60c} + {2e3aca1d-223d-10a1-b282-7f9fc68ee6f5} From df77c580dc62f17d848f1899e72501d60b098320 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Tue, 23 Jun 2015 16:34:18 -0700 Subject: [PATCH 028/124] Added support for passing a tag with the test --- test/cpp/qps/perf_db.proto | 14 ++++++++------ test/cpp/qps/perf_db_client.cc | 3 ++- test/cpp/qps/perf_db_client.h | 2 +- test/cpp/qps/report.cc | 2 +- test/cpp/qps/report.h | 6 ++++-- test/cpp/util/benchmark_config.cc | 5 ++++- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/test/cpp/qps/perf_db.proto b/test/cpp/qps/perf_db.proto index 50070fda5b6..7f4a460812f 100644 --- a/test/cpp/qps/perf_db.proto +++ b/test/cpp/qps/perf_db.proto @@ -62,9 +62,10 @@ message DataDetails { string timestamp = 1; string test_name = 2; string sys_info = 3; - Metrics metrics = 4; - ClientConfig client_config = 5; - ServerConfig server_config = 6; + string tag = 4; + Metrics metrics = 5; + ClientConfig client_config = 6; + ServerConfig server_config = 7; } //User details @@ -93,9 +94,10 @@ message SingleUserRecordRequest { string access_token = 1; string test_name = 2; string sys_info = 3; - Metrics metrics = 4; - ClientConfig client_config = 5; - ServerConfig server_config = 6; + string tag = 4; + Metrics metrics = 5; + ClientConfig client_config = 6; + ServerConfig server_config = 7; } //Reply to request for storing single user's data diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 0905cde11a0..c3a170b398d 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -72,7 +72,7 @@ void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, } //sends the data to the performancew database server -int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info) { +int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag) { //Data record request object SingleUserRecordRequest singleUserRecordRequest; @@ -80,6 +80,7 @@ int PerfDbClient::sendData(std::string access_token, std::string test_name, std: singleUserRecordRequest.set_access_token(access_token); singleUserRecordRequest.set_test_name(test_name); singleUserRecordRequest.set_sys_info(sys_info); + singleUserRecordRequest.set_tag(tag); //setting configs *(singleUserRecordRequest.mutable_client_config()) = this->clientConfig_; diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index c19442f35e5..be4766ab055 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -88,7 +88,7 @@ public: double clientSystemTime, double clientUserTime); //sends the data to the performancew database server - int sendData(std::string access_token, std::string test_name, std::string sys_info); + int sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag); private: std::unique_ptr stub_; diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 59c0da31fb9..7167d4e336a 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -173,7 +173,7 @@ void PerfDbReporter::ReportTimes(const ScenarioResult& result) { void PerfDbReporter::SendData() { //send data to performance database - int dataState = perfDbClient_.sendData(access_token_, test_name_, sys_info_); + int dataState = perfDbClient_.sendData(access_token_, test_name_, sys_info_, tag_); //check state of data sending switch(dataState) { diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index bba26b990cf..565590649ab 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -107,8 +107,9 @@ class GprLogReporter : public Reporter { /** Reporter for performance database tool */ class PerfDbReporter : public Reporter { public: - PerfDbReporter(const string& name, const string& access_token, const string& test_name, const string& sys_info, const string& server_address) - : Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info) { + PerfDbReporter(const string& name, const string& access_token, const string& test_name, + const string& sys_info, const string& server_address, const string& tag) + : Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info), tag_(tag) { perfDbClient_.init(grpc::CreateChannel(server_address, grpc::InsecureCredentials(), ChannelArguments())); } ~PerfDbReporter() { SendData(); }; @@ -118,6 +119,7 @@ class PerfDbReporter : public Reporter { std::string access_token_; std::string test_name_; std::string sys_info_; + std::string tag_; void ReportQPS(const ScenarioResult& result) GRPC_OVERRIDE; void ReportQPSPerCore(const ScenarioResult& result) GRPC_OVERRIDE; void ReportLatency(const ScenarioResult& result) GRPC_OVERRIDE; diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index f8cfabd0d68..030cb28c32f 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -47,6 +47,8 @@ DEFINE_string(sys_info, "", "System information"); DEFINE_string(server_address, "localhost:50052", "Address of the performance database server"); +DEFINE_string(tag, "", "Optional tag for the test"); + // In some distros, gflags is in the namespace google, and in some others, // in gflags. This hack is enabling us to find both. namespace google {} @@ -69,7 +71,8 @@ static std::shared_ptr InitBenchmarkReporters() { } if(FLAGS_report_metrics_db) { composite_reporter->add( - std::unique_ptr(new PerfDbReporter("PerfDbReporter", FLAGS_access_token, FLAGS_test_name, FLAGS_sys_info, FLAGS_server_address))); + std::unique_ptr(new PerfDbReporter("PerfDbReporter", FLAGS_access_token, FLAGS_test_name, + FLAGS_sys_info, FLAGS_server_address, FLAGS_tag))); } return std::shared_ptr(composite_reporter); From cd29c58c3778bef10dd2d9d4313684d534f4d492 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 24 Jun 2015 09:15:15 -0700 Subject: [PATCH 029/124] Stub DNS resolver --- .../client_config/resolvers/dns_resolver.c | 36 +++++++++++++++++ .../client_config/resolvers/dns_resolver.h | 40 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/core/client_config/resolvers/dns_resolver.c create mode 100644 src/core/client_config/resolvers/dns_resolver.h diff --git a/src/core/client_config/resolvers/dns_resolver.c b/src/core/client_config/resolvers/dns_resolver.c new file mode 100644 index 00000000000..187ff26466e --- /dev/null +++ b/src/core/client_config/resolvers/dns_resolver.c @@ -0,0 +1,36 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/resolvers/dns_resolver.h" + + \ No newline at end of file diff --git a/src/core/client_config/resolvers/dns_resolver.h b/src/core/client_config/resolvers/dns_resolver.h new file mode 100644 index 00000000000..fc32baa15b6 --- /dev/null +++ b/src/core/client_config/resolvers/dns_resolver.h @@ -0,0 +1,40 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H + +/** Create a dns resolver for \a name */ +grpc_resolver *grpc_dns_resolver_create(const char *name); + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H */ From 1b81cc40cdedd8faed13ba3f9150cfb6159f05b3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 24 Jun 2015 09:24:40 -0700 Subject: [PATCH 030/124] Missed file --- build.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.json b/build.json index c062a940a4c..3b71f631553 100644 --- a/build.json +++ b/build.json @@ -122,6 +122,7 @@ "src/core/client_config/client_config.h", "src/core/client_config/lb_policy.h", "src/core/client_config/resolver.h", + "src/core/client_config/resolver_factory.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", "src/core/compression/message_compress.h", @@ -210,6 +211,7 @@ "src/core/client_config/client_config.c", "src/core/client_config/lb_policy.c", "src/core/client_config/resolver.c", + "src/core/client_config/resolver_factory.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", "src/core/compression/algorithm.c", From 3bc8ebd48eceab0fc9fe2ef4f7a94c1f937172ba Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 24 Jun 2015 15:41:15 -0700 Subject: [PATCH 031/124] Implementation work for client_config - uri parsing - dns resolution --- BUILD | 16 ++ Makefile | 42 +++- build.json | 22 ++ gRPC.podspec | 4 +- src/core/client_config/client_config.h | 1 + .../client_config/lb_policies/pick_first.c | 34 +++ .../client_config/lb_policies/pick_first.h | 42 ++++ src/core/client_config/resolver.h | 3 +- src/core/client_config/resolver_factory.h | 29 ++- src/core/client_config/resolver_registry.c | 102 ++++++++ src/core/client_config/resolver_registry.h | 54 +++++ .../client_config/resolvers/dns_resolver.c | 227 +++++++++++++++++- .../client_config/resolvers/dns_resolver.h | 7 +- src/core/client_config/subchannel_factory.h | 5 +- src/core/client_config/uri_parser.c | 169 +++++++++++++ src/core/client_config/uri_parser.h | 52 ++++ test/core/client_config/uri_parser_test.c | 68 ++++++ tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/tests.json | 9 + vsprojects/Grpc.mak | 9 +- vsprojects/grpc/grpc.vcxproj | 12 + vsprojects/grpc/grpc.vcxproj.filters | 30 +++ .../grpc_unsecure/grpc_unsecure.vcxproj | 12 + .../grpc_unsecure.vcxproj.filters | 30 +++ 24 files changed, 957 insertions(+), 24 deletions(-) create mode 100644 src/core/client_config/lb_policies/pick_first.c create mode 100644 src/core/client_config/lb_policies/pick_first.h create mode 100644 src/core/client_config/resolver_registry.c create mode 100644 src/core/client_config/resolver_registry.h create mode 100644 src/core/client_config/uri_parser.c create mode 100644 src/core/client_config/uri_parser.h create mode 100644 test/core/client_config/uri_parser_test.c diff --git a/BUILD b/BUILD index 438e06b5fc2..6e1bec95f5b 100644 --- a/BUILD +++ b/BUILD @@ -159,11 +159,15 @@ cc_library( "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", "src/core/client_config/client_config.h", + "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policy.h", "src/core/client_config/resolver.h", "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -270,11 +274,15 @@ cc_library( "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", "src/core/client_config/client_config.c", + "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policy.c", "src/core/client_config/resolver.c", "src/core/client_config/resolver_factory.c", + "src/core/client_config/resolver_registry.c", + "src/core/client_config/resolvers/dns_resolver.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", + "src/core/client_config/uri_parser.c", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/debug/trace.c", @@ -397,11 +405,15 @@ cc_library( "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", "src/core/client_config/client_config.h", + "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policy.h", "src/core/client_config/resolver.h", "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -486,11 +498,15 @@ cc_library( "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", "src/core/client_config/client_config.c", + "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policy.c", "src/core/client_config/resolver.c", "src/core/client_config/resolver_factory.c", + "src/core/client_config/resolver_registry.c", + "src/core/client_config/resolvers/dns_resolver.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", + "src/core/client_config/uri_parser.c", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/debug/trace.c", diff --git a/Makefile b/Makefile index 84283c9c551..6b70396f2bc 100644 --- a/Makefile +++ b/Makefile @@ -663,6 +663,7 @@ timeout_encoding_test: $(BINDIR)/$(CONFIG)/timeout_encoding_test timers_test: $(BINDIR)/$(CONFIG)/timers_test transport_metadata_test: $(BINDIR)/$(CONFIG)/transport_metadata_test transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test +uri_parser_test: $(BINDIR)/$(CONFIG)/uri_parser_test async_end2end_test: $(BINDIR)/$(CONFIG)/async_end2end_test async_streaming_ping_pong_test: $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test async_unary_ping_pong_test: $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test @@ -1265,7 +1266,7 @@ privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(C buildtests: buildtests_c buildtests_cxx -buildtests_c: privatelibs_c $(BINDIR)/$(CONFIG)/alarm_heap_test $(BINDIR)/$(CONFIG)/alarm_list_test $(BINDIR)/$(CONFIG)/alarm_test $(BINDIR)/$(CONFIG)/alpn_test $(BINDIR)/$(CONFIG)/bin_encoder_test $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test $(BINDIR)/$(CONFIG)/chttp2_stream_encoder_test $(BINDIR)/$(CONFIG)/chttp2_stream_map_test $(BINDIR)/$(CONFIG)/dualstack_socket_test $(BINDIR)/$(CONFIG)/fd_posix_test $(BINDIR)/$(CONFIG)/fling_client $(BINDIR)/$(CONFIG)/fling_server $(BINDIR)/$(CONFIG)/fling_stream_test $(BINDIR)/$(CONFIG)/fling_test $(BINDIR)/$(CONFIG)/gpr_cancellable_test $(BINDIR)/$(CONFIG)/gpr_cmdline_test $(BINDIR)/$(CONFIG)/gpr_env_test $(BINDIR)/$(CONFIG)/gpr_file_test $(BINDIR)/$(CONFIG)/gpr_histogram_test $(BINDIR)/$(CONFIG)/gpr_host_port_test $(BINDIR)/$(CONFIG)/gpr_log_test $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test $(BINDIR)/$(CONFIG)/gpr_slice_test $(BINDIR)/$(CONFIG)/gpr_string_test $(BINDIR)/$(CONFIG)/gpr_sync_test $(BINDIR)/$(CONFIG)/gpr_thd_test $(BINDIR)/$(CONFIG)/gpr_time_test $(BINDIR)/$(CONFIG)/gpr_tls_test $(BINDIR)/$(CONFIG)/gpr_useful_test $(BINDIR)/$(CONFIG)/grpc_auth_context_test $(BINDIR)/$(CONFIG)/grpc_base64_test $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test $(BINDIR)/$(CONFIG)/grpc_channel_stack_test $(BINDIR)/$(CONFIG)/grpc_completion_queue_test $(BINDIR)/$(CONFIG)/grpc_credentials_test $(BINDIR)/$(CONFIG)/grpc_json_token_test $(BINDIR)/$(CONFIG)/grpc_security_connector_test $(BINDIR)/$(CONFIG)/grpc_stream_op_test $(BINDIR)/$(CONFIG)/hpack_parser_test $(BINDIR)/$(CONFIG)/hpack_table_test $(BINDIR)/$(CONFIG)/httpcli_format_request_test $(BINDIR)/$(CONFIG)/httpcli_parser_test $(BINDIR)/$(CONFIG)/httpcli_test $(BINDIR)/$(CONFIG)/json_rewrite $(BINDIR)/$(CONFIG)/json_rewrite_test $(BINDIR)/$(CONFIG)/json_test $(BINDIR)/$(CONFIG)/lame_client_test $(BINDIR)/$(CONFIG)/message_compress_test $(BINDIR)/$(CONFIG)/multi_init_test $(BINDIR)/$(CONFIG)/murmur_hash_test $(BINDIR)/$(CONFIG)/no_server_test $(BINDIR)/$(CONFIG)/poll_kick_posix_test $(BINDIR)/$(CONFIG)/resolve_address_test $(BINDIR)/$(CONFIG)/secure_endpoint_test $(BINDIR)/$(CONFIG)/sockaddr_utils_test $(BINDIR)/$(CONFIG)/tcp_client_posix_test $(BINDIR)/$(CONFIG)/tcp_posix_test $(BINDIR)/$(CONFIG)/tcp_server_posix_test $(BINDIR)/$(CONFIG)/time_averaged_stats_test $(BINDIR)/$(CONFIG)/time_test $(BINDIR)/$(CONFIG)/timeout_encoding_test $(BINDIR)/$(CONFIG)/timers_test $(BINDIR)/$(CONFIG)/transport_metadata_test $(BINDIR)/$(CONFIG)/transport_security_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test +buildtests_c: privatelibs_c $(BINDIR)/$(CONFIG)/alarm_heap_test $(BINDIR)/$(CONFIG)/alarm_list_test $(BINDIR)/$(CONFIG)/alarm_test $(BINDIR)/$(CONFIG)/alpn_test $(BINDIR)/$(CONFIG)/bin_encoder_test $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test $(BINDIR)/$(CONFIG)/chttp2_stream_encoder_test $(BINDIR)/$(CONFIG)/chttp2_stream_map_test $(BINDIR)/$(CONFIG)/dualstack_socket_test $(BINDIR)/$(CONFIG)/fd_posix_test $(BINDIR)/$(CONFIG)/fling_client $(BINDIR)/$(CONFIG)/fling_server $(BINDIR)/$(CONFIG)/fling_stream_test $(BINDIR)/$(CONFIG)/fling_test $(BINDIR)/$(CONFIG)/gpr_cancellable_test $(BINDIR)/$(CONFIG)/gpr_cmdline_test $(BINDIR)/$(CONFIG)/gpr_env_test $(BINDIR)/$(CONFIG)/gpr_file_test $(BINDIR)/$(CONFIG)/gpr_histogram_test $(BINDIR)/$(CONFIG)/gpr_host_port_test $(BINDIR)/$(CONFIG)/gpr_log_test $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test $(BINDIR)/$(CONFIG)/gpr_slice_test $(BINDIR)/$(CONFIG)/gpr_string_test $(BINDIR)/$(CONFIG)/gpr_sync_test $(BINDIR)/$(CONFIG)/gpr_thd_test $(BINDIR)/$(CONFIG)/gpr_time_test $(BINDIR)/$(CONFIG)/gpr_tls_test $(BINDIR)/$(CONFIG)/gpr_useful_test $(BINDIR)/$(CONFIG)/grpc_auth_context_test $(BINDIR)/$(CONFIG)/grpc_base64_test $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test $(BINDIR)/$(CONFIG)/grpc_channel_stack_test $(BINDIR)/$(CONFIG)/grpc_completion_queue_test $(BINDIR)/$(CONFIG)/grpc_credentials_test $(BINDIR)/$(CONFIG)/grpc_json_token_test $(BINDIR)/$(CONFIG)/grpc_security_connector_test $(BINDIR)/$(CONFIG)/grpc_stream_op_test $(BINDIR)/$(CONFIG)/hpack_parser_test $(BINDIR)/$(CONFIG)/hpack_table_test $(BINDIR)/$(CONFIG)/httpcli_format_request_test $(BINDIR)/$(CONFIG)/httpcli_parser_test $(BINDIR)/$(CONFIG)/httpcli_test $(BINDIR)/$(CONFIG)/json_rewrite $(BINDIR)/$(CONFIG)/json_rewrite_test $(BINDIR)/$(CONFIG)/json_test $(BINDIR)/$(CONFIG)/lame_client_test $(BINDIR)/$(CONFIG)/message_compress_test $(BINDIR)/$(CONFIG)/multi_init_test $(BINDIR)/$(CONFIG)/murmur_hash_test $(BINDIR)/$(CONFIG)/no_server_test $(BINDIR)/$(CONFIG)/poll_kick_posix_test $(BINDIR)/$(CONFIG)/resolve_address_test $(BINDIR)/$(CONFIG)/secure_endpoint_test $(BINDIR)/$(CONFIG)/sockaddr_utils_test $(BINDIR)/$(CONFIG)/tcp_client_posix_test $(BINDIR)/$(CONFIG)/tcp_posix_test $(BINDIR)/$(CONFIG)/tcp_server_posix_test $(BINDIR)/$(CONFIG)/time_averaged_stats_test $(BINDIR)/$(CONFIG)/time_test $(BINDIR)/$(CONFIG)/timeout_encoding_test $(BINDIR)/$(CONFIG)/timers_test $(BINDIR)/$(CONFIG)/transport_metadata_test $(BINDIR)/$(CONFIG)/transport_security_test $(BINDIR)/$(CONFIG)/uri_parser_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_with_poll_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_message_length_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_registered_call_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_payload_and_call_creds_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_flags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_server_finishes_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_posix_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_with_poll_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_bad_hostname_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_census_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_disappearing_server_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_empty_batch_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_invoke_large_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_max_message_length_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_no_op_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_registered_call_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_flags_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_request_with_payload_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_server_finishes_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_delayed_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_unsecure_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_unsecure_test $(BINDIR)/$(CONFIG)/connection_prefix_bad_client_test $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test buildtests_cxx: privatelibs_cxx $(BINDIR)/$(CONFIG)/async_end2end_test $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test $(BINDIR)/$(CONFIG)/channel_arguments_test $(BINDIR)/$(CONFIG)/cli_call_test $(BINDIR)/$(CONFIG)/client_crash_test $(BINDIR)/$(CONFIG)/client_crash_test_server $(BINDIR)/$(CONFIG)/credentials_test $(BINDIR)/$(CONFIG)/cxx_byte_buffer_test $(BINDIR)/$(CONFIG)/cxx_slice_test $(BINDIR)/$(CONFIG)/cxx_time_test $(BINDIR)/$(CONFIG)/end2end_test $(BINDIR)/$(CONFIG)/generic_end2end_test $(BINDIR)/$(CONFIG)/grpc_cli $(BINDIR)/$(CONFIG)/interop_client $(BINDIR)/$(CONFIG)/interop_server $(BINDIR)/$(CONFIG)/interop_test $(BINDIR)/$(CONFIG)/mock_test $(BINDIR)/$(CONFIG)/qps_interarrival_test $(BINDIR)/$(CONFIG)/qps_test $(BINDIR)/$(CONFIG)/qps_test_openloop $(BINDIR)/$(CONFIG)/server_crash_test $(BINDIR)/$(CONFIG)/server_crash_test_client $(BINDIR)/$(CONFIG)/status_test $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test $(BINDIR)/$(CONFIG)/thread_pool_test $(BINDIR)/$(CONFIG)/thread_stress_test @@ -1396,6 +1397,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/transport_metadata_test || ( echo test transport_metadata_test failed ; exit 1 ) $(E) "[RUN] Testing transport_security_test" $(Q) $(BINDIR)/$(CONFIG)/transport_security_test || ( echo test transport_security_test failed ; exit 1 ) + $(E) "[RUN] Testing uri_parser_test" + $(Q) $(BINDIR)/$(CONFIG)/uri_parser_test || ( echo test uri_parser_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_fake_security_bad_hostname_test" $(Q) $(BINDIR)/$(CONFIG)/chttp2_fake_security_bad_hostname_test || ( echo test chttp2_fake_security_bad_hostname_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_fake_security_cancel_after_accept_test" @@ -3021,11 +3024,15 @@ LIBGRPC_SRC = \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ src/core/client_config/client_config.c \ + src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policy.c \ src/core/client_config/resolver.c \ src/core/client_config/resolver_factory.c \ + src/core/client_config/resolver_registry.c \ + src/core/client_config/resolvers/dns_resolver.c \ src/core/client_config/subchannel.c \ src/core/client_config/subchannel_factory.c \ + src/core/client_config/uri_parser.c \ src/core/compression/algorithm.c \ src/core/compression/message_compress.c \ src/core/debug/trace.c \ @@ -3273,11 +3280,15 @@ LIBGRPC_UNSECURE_SRC = \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ src/core/client_config/client_config.c \ + src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policy.c \ src/core/client_config/resolver.c \ src/core/client_config/resolver_factory.c \ + src/core/client_config/resolver_registry.c \ + src/core/client_config/resolvers/dns_resolver.c \ src/core/client_config/subchannel.c \ src/core/client_config/subchannel_factory.c \ + src/core/client_config/uri_parser.c \ src/core/compression/algorithm.c \ src/core/compression/message_compress.c \ src/core/debug/trace.c \ @@ -7297,6 +7308,35 @@ endif endif +URI_PARSER_TEST_SRC = \ + test/core/client_config/uri_parser_test.c \ + +URI_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(URI_PARSER_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL with ALPN. + +$(BINDIR)/$(CONFIG)/uri_parser_test: openssl_dep_error + +else + +$(BINDIR)/$(CONFIG)/uri_parser_test: $(URI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(URI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/uri_parser_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/client_config/uri_parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +deps_uri_parser_test: $(URI_PARSER_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(URI_PARSER_TEST_OBJS:.o=.dep) +endif +endif + + ASYNC_END2END_TEST_SRC = \ test/cpp/end2end/async_end2end_test.cc \ diff --git a/build.json b/build.json index 3b71f631553..71f4fd8e0b0 100644 --- a/build.json +++ b/build.json @@ -120,11 +120,15 @@ "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", "src/core/client_config/client_config.h", + "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policy.h", "src/core/client_config/resolver.h", "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -209,11 +213,15 @@ "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", "src/core/client_config/client_config.c", + "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policy.c", "src/core/client_config/resolver.c", "src/core/client_config/resolver_factory.c", + "src/core/client_config/resolver_registry.c", + "src/core/client_config/resolvers/dns_resolver.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", + "src/core/client_config/uri_parser.c", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/debug/trace.c", @@ -1715,6 +1723,20 @@ "gpr" ] }, + { + "name": "uri_parser_test", + "build": "test", + "language": "c", + "src": [ + "test/core/client_config/uri_parser_test.c" + ], + "deps": [ + "grpc_test_util", + "grpc", + "gpr_test_util", + "gpr" + ] + }, { "name": "async_end2end_test", "build": "test", diff --git a/gRPC.podspec b/gRPC.podspec index b3dd6478c05..8564d3aa377 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -61,8 +61,8 @@ Pod::Spec.new do |s| # Core cross-platform gRPC library, written in C. s.subspec 'C-Core' do |ss| - ss.source_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/grpc_string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'grpc/support/alloc.h', 'grpc/support/atm.h', 'grpc/support/atm_gcc_atomic.h', 'grpc/support/atm_gcc_sync.h', 'grpc/support/atm_win32.h', 'grpc/support/cancellable_platform.h', 'grpc/support/cmdline.h', 'grpc/support/cpu.h', 'grpc/support/histogram.h', 'grpc/support/host_port.h', 'grpc/support/log.h', 'grpc/support/log_win32.h', 'grpc/support/port_platform.h', 'grpc/support/slice.h', 'grpc/support/slice_buffer.h', 'grpc/support/string_util.h', 'grpc/support/subprocess.h', 'grpc/support/sync.h', 'grpc/support/sync_generic.h', 'grpc/support/sync_posix.h', 'grpc/support/sync_win32.h', 'grpc/support/thd.h', 'grpc/support/grpc_time.h', 'grpc/support/tls.h', 'grpc/support/tls_gcc.h', 'grpc/support/tls_msvc.h', 'grpc/support/tls_pthread.h', 'grpc/support/useful.h', 'src/core/support/alloc.c', 'src/core/support/cancellable.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', 'src/core/support/cpu_linux.c', 'src/core/support/cpu_posix.c', 'src/core/support/cpu_windows.c', 'src/core/support/env_linux.c', 'src/core/support/env_posix.c', 'src/core/support/env_win32.c', 'src/core/support/file.c', 'src/core/support/file_posix.c', 'src/core/support/file_win32.c', 'src/core/support/histogram.c', 'src/core/support/host_port.c', 'src/core/support/log.c', 'src/core/support/log_android.c', 'src/core/support/log_linux.c', 'src/core/support/log_posix.c', 'src/core/support/log_win32.c', 'src/core/support/murmur_hash.c', 'src/core/support/slice.c', 'src/core/support/slice_buffer.c', 'src/core/support/string.c', 'src/core/support/string_posix.c', 'src/core/support/string_win32.c', 'src/core/support/subprocess_posix.c', 'src/core/support/sync.c', 'src/core/support/sync_posix.c', 'src/core/support/sync_win32.c', 'src/core/support/thd.c', 'src/core/support/thd_posix.c', 'src/core/support/thd_win32.c', 'src/core/support/time.c', 'src/core/support/time_posix.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', 'grpc/grpc_security.h', 'grpc/byte_buffer.h', 'grpc/byte_buffer_reader.h', 'grpc/compression.h', 'grpc/grpc.h', 'grpc/status.h', 'grpc/census.h', 'src/core/httpcli/format_request.c', 'src/core/httpcli/httpcli.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/httpcli/parser.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', 'src/core/security/credentials.c', 'src/core/security/credentials_metadata.c', 'src/core/security/credentials_posix.c', 'src/core/security/credentials_win32.c', 'src/core/security/google_default_credentials.c', 'src/core/security/json_token.c', 'src/core/security/secure_endpoint.c', 'src/core/security/secure_transport_setup.c', 'src/core/security/security_connector.c', 'src/core/security/security_context.c', 'src/core/security/server_auth_filter.c', 'src/core/security/server_secure_chttp2.c', 'src/core/surface/init_secure.c', 'src/core/surface/secure_channel_create.c', 'src/core/tsi/fake_transport_security.c', 'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/transport_security.c', 'src/core/census/grpc_context.c', 'src/core/channel/channel_args.c', 'src/core/channel/channel_stack.c', 'src/core/channel/child_channel.c', 'src/core/channel/client_channel.c', 'src/core/channel/client_setup.c', 'src/core/channel/connected_channel.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', 'src/core/client_config/client_config.c', 'src/core/client_config/lb_policy.c', 'src/core/client_config/resolver.c', 'src/core/client_config/resolver_factory.c', 'src/core/client_config/subchannel.c', 'src/core/client_config/subchannel_factory.c', 'src/core/compression/algorithm.c', 'src/core/compression/message_compress.c', 'src/core/debug/trace.c', 'src/core/iomgr/alarm.c', 'src/core/iomgr/alarm_heap.c', 'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_windows.c', 'src/core/iomgr/fd_posix.c', 'src/core/iomgr/iocp_windows.c', 'src/core/iomgr/iomgr.c', 'src/core/iomgr/iomgr_posix.c', 'src/core/iomgr/iomgr_windows.c', 'src/core/iomgr/pollset_kick_posix.c', 'src/core/iomgr/pollset_multipoller_with_epoll.c', 'src/core/iomgr/pollset_multipoller_with_poll_posix.c', 'src/core/iomgr/pollset_posix.c', 'src/core/iomgr/pollset_set_posix.c', 'src/core/iomgr/pollset_set_windows.c', 'src/core/iomgr/pollset_windows.c', 'src/core/iomgr/resolve_address_posix.c', 'src/core/iomgr/resolve_address_windows.c', 'src/core/iomgr/sockaddr_utils.c', 'src/core/iomgr/socket_utils_common_posix.c', 'src/core/iomgr/socket_utils_linux.c', 'src/core/iomgr/socket_utils_posix.c', 'src/core/iomgr/socket_windows.c', 'src/core/iomgr/tcp_client_posix.c', 'src/core/iomgr/tcp_client_windows.c', 'src/core/iomgr/tcp_posix.c', 'src/core/iomgr/tcp_server_posix.c', 'src/core/iomgr/tcp_server_windows.c', 'src/core/iomgr/tcp_windows.c', 'src/core/iomgr/time_averaged_stats.c', 'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_posix.c', 'src/core/json/json.c', 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', 'src/core/profiling/basic_timers.c', 'src/core/profiling/stap_timers.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', 'src/core/surface/byte_buffer_reader.c', 'src/core/surface/call.c', 'src/core/surface/call_details.c', 'src/core/surface/call_log_batch.c', 'src/core/surface/channel.c', 'src/core/surface/channel_create.c', 'src/core/surface/client.c', 'src/core/surface/completion_queue.c', 'src/core/surface/event_string.c', 'src/core/surface/init.c', 'src/core/surface/lame_client.c', 'src/core/surface/metadata_array.c', 'src/core/surface/server.c', 'src/core/surface/server_chttp2.c', 'src/core/surface/server_create.c', 'src/core/surface/surface_trace.c', 'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/bin_encoder.c', 'src/core/transport/chttp2/frame_data.c', 'src/core/transport/chttp2/frame_goaway.c', 'src/core/transport/chttp2/frame_ping.c', 'src/core/transport/chttp2/frame_rst_stream.c', 'src/core/transport/chttp2/frame_settings.c', 'src/core/transport/chttp2/frame_window_update.c', 'src/core/transport/chttp2/hpack_parser.c', 'src/core/transport/chttp2/hpack_table.c', 'src/core/transport/chttp2/huffsyms.c', 'src/core/transport/chttp2/status_conversion.c', 'src/core/transport/chttp2/stream_encoder.c', 'src/core/transport/chttp2/stream_map.c', 'src/core/transport/chttp2/timeout_encoding.c', 'src/core/transport/chttp2/varint.c', 'src/core/transport/chttp2_transport.c', 'src/core/transport/metadata.c', 'src/core/transport/stream_op.c', 'src/core/transport/transport.c', 'src/core/transport/transport_op_string.c', 'src/core/census/context.c', 'src/core/census/initialize.c', - ss.private_header_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', + ss.source_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/grpc_string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'grpc/support/alloc.h', 'grpc/support/atm.h', 'grpc/support/atm_gcc_atomic.h', 'grpc/support/atm_gcc_sync.h', 'grpc/support/atm_win32.h', 'grpc/support/cancellable_platform.h', 'grpc/support/cmdline.h', 'grpc/support/cpu.h', 'grpc/support/histogram.h', 'grpc/support/host_port.h', 'grpc/support/log.h', 'grpc/support/log_win32.h', 'grpc/support/port_platform.h', 'grpc/support/slice.h', 'grpc/support/slice_buffer.h', 'grpc/support/string_util.h', 'grpc/support/subprocess.h', 'grpc/support/sync.h', 'grpc/support/sync_generic.h', 'grpc/support/sync_posix.h', 'grpc/support/sync_win32.h', 'grpc/support/thd.h', 'grpc/support/grpc_time.h', 'grpc/support/tls.h', 'grpc/support/tls_gcc.h', 'grpc/support/tls_msvc.h', 'grpc/support/tls_pthread.h', 'grpc/support/useful.h', 'src/core/support/alloc.c', 'src/core/support/cancellable.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', 'src/core/support/cpu_linux.c', 'src/core/support/cpu_posix.c', 'src/core/support/cpu_windows.c', 'src/core/support/env_linux.c', 'src/core/support/env_posix.c', 'src/core/support/env_win32.c', 'src/core/support/file.c', 'src/core/support/file_posix.c', 'src/core/support/file_win32.c', 'src/core/support/histogram.c', 'src/core/support/host_port.c', 'src/core/support/log.c', 'src/core/support/log_android.c', 'src/core/support/log_linux.c', 'src/core/support/log_posix.c', 'src/core/support/log_win32.c', 'src/core/support/murmur_hash.c', 'src/core/support/slice.c', 'src/core/support/slice_buffer.c', 'src/core/support/string.c', 'src/core/support/string_posix.c', 'src/core/support/string_win32.c', 'src/core/support/subprocess_posix.c', 'src/core/support/sync.c', 'src/core/support/sync_posix.c', 'src/core/support/sync_win32.c', 'src/core/support/thd.c', 'src/core/support/thd_posix.c', 'src/core/support/thd_win32.c', 'src/core/support/time.c', 'src/core/support/time_posix.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', 'grpc/grpc_security.h', 'grpc/byte_buffer.h', 'grpc/byte_buffer_reader.h', 'grpc/compression.h', 'grpc/grpc.h', 'grpc/status.h', 'grpc/census.h', 'src/core/httpcli/format_request.c', 'src/core/httpcli/httpcli.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/httpcli/parser.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', 'src/core/security/credentials.c', 'src/core/security/credentials_metadata.c', 'src/core/security/credentials_posix.c', 'src/core/security/credentials_win32.c', 'src/core/security/google_default_credentials.c', 'src/core/security/json_token.c', 'src/core/security/secure_endpoint.c', 'src/core/security/secure_transport_setup.c', 'src/core/security/security_connector.c', 'src/core/security/security_context.c', 'src/core/security/server_auth_filter.c', 'src/core/security/server_secure_chttp2.c', 'src/core/surface/init_secure.c', 'src/core/surface/secure_channel_create.c', 'src/core/tsi/fake_transport_security.c', 'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/transport_security.c', 'src/core/census/grpc_context.c', 'src/core/channel/channel_args.c', 'src/core/channel/channel_stack.c', 'src/core/channel/child_channel.c', 'src/core/channel/client_channel.c', 'src/core/channel/client_setup.c', 'src/core/channel/connected_channel.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', 'src/core/client_config/client_config.c', 'src/core/client_config/lb_policies/pick_first.c', 'src/core/client_config/lb_policy.c', 'src/core/client_config/resolver.c', 'src/core/client_config/resolver_factory.c', 'src/core/client_config/resolver_registry.c', 'src/core/client_config/resolvers/dns_resolver.c', 'src/core/client_config/subchannel.c', 'src/core/client_config/subchannel_factory.c', 'src/core/client_config/uri_parser.c', 'src/core/compression/algorithm.c', 'src/core/compression/message_compress.c', 'src/core/debug/trace.c', 'src/core/iomgr/alarm.c', 'src/core/iomgr/alarm_heap.c', 'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_windows.c', 'src/core/iomgr/fd_posix.c', 'src/core/iomgr/iocp_windows.c', 'src/core/iomgr/iomgr.c', 'src/core/iomgr/iomgr_posix.c', 'src/core/iomgr/iomgr_windows.c', 'src/core/iomgr/pollset_kick_posix.c', 'src/core/iomgr/pollset_multipoller_with_epoll.c', 'src/core/iomgr/pollset_multipoller_with_poll_posix.c', 'src/core/iomgr/pollset_posix.c', 'src/core/iomgr/pollset_set_posix.c', 'src/core/iomgr/pollset_set_windows.c', 'src/core/iomgr/pollset_windows.c', 'src/core/iomgr/resolve_address_posix.c', 'src/core/iomgr/resolve_address_windows.c', 'src/core/iomgr/sockaddr_utils.c', 'src/core/iomgr/socket_utils_common_posix.c', 'src/core/iomgr/socket_utils_linux.c', 'src/core/iomgr/socket_utils_posix.c', 'src/core/iomgr/socket_windows.c', 'src/core/iomgr/tcp_client_posix.c', 'src/core/iomgr/tcp_client_windows.c', 'src/core/iomgr/tcp_posix.c', 'src/core/iomgr/tcp_server_posix.c', 'src/core/iomgr/tcp_server_windows.c', 'src/core/iomgr/tcp_windows.c', 'src/core/iomgr/time_averaged_stats.c', 'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_posix.c', 'src/core/json/json.c', 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', 'src/core/profiling/basic_timers.c', 'src/core/profiling/stap_timers.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', 'src/core/surface/byte_buffer_reader.c', 'src/core/surface/call.c', 'src/core/surface/call_details.c', 'src/core/surface/call_log_batch.c', 'src/core/surface/channel.c', 'src/core/surface/channel_create.c', 'src/core/surface/client.c', 'src/core/surface/completion_queue.c', 'src/core/surface/event_string.c', 'src/core/surface/init.c', 'src/core/surface/lame_client.c', 'src/core/surface/metadata_array.c', 'src/core/surface/server.c', 'src/core/surface/server_chttp2.c', 'src/core/surface/server_create.c', 'src/core/surface/surface_trace.c', 'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/bin_encoder.c', 'src/core/transport/chttp2/frame_data.c', 'src/core/transport/chttp2/frame_goaway.c', 'src/core/transport/chttp2/frame_ping.c', 'src/core/transport/chttp2/frame_rst_stream.c', 'src/core/transport/chttp2/frame_settings.c', 'src/core/transport/chttp2/frame_window_update.c', 'src/core/transport/chttp2/hpack_parser.c', 'src/core/transport/chttp2/hpack_table.c', 'src/core/transport/chttp2/huffsyms.c', 'src/core/transport/chttp2/status_conversion.c', 'src/core/transport/chttp2/stream_encoder.c', 'src/core/transport/chttp2/stream_map.c', 'src/core/transport/chttp2/timeout_encoding.c', 'src/core/transport/chttp2/varint.c', 'src/core/transport/chttp2_transport.c', 'src/core/transport/metadata.c', 'src/core/transport/stream_op.c', 'src/core/transport/transport.c', 'src/core/transport/transport_op_string.c', 'src/core/census/context.c', 'src/core/census/initialize.c', + ss.private_header_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', ss.header_mappings_dir = '.' ss.requires_arc = false diff --git a/src/core/client_config/client_config.h b/src/core/client_config/client_config.h index 44d281f6715..47612da42cf 100644 --- a/src/core/client_config/client_config.h +++ b/src/core/client_config/client_config.h @@ -40,6 +40,7 @@ grpc_resolver */ typedef struct grpc_client_config grpc_client_config; +grpc_client_config *grpc_client_config_create(); void grpc_client_config_ref(grpc_client_config *client_config); void grpc_client_config_unref(grpc_client_config *client_config); diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c new file mode 100644 index 00000000000..46732b8444a --- /dev/null +++ b/src/core/client_config/lb_policies/pick_first.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/lb_policies/pick_first.h" diff --git a/src/core/client_config/lb_policies/pick_first.h b/src/core/client_config/lb_policies/pick_first.h new file mode 100644 index 00000000000..94c2a9f0c75 --- /dev/null +++ b/src/core/client_config/lb_policies/pick_first.h @@ -0,0 +1,42 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_PICK_FIRST_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_PICK_FIRST_H + +#include "src/core/client_config/lb_policy.h" + +grpc_lb_policy *grpc_create_pick_first_lb_policy(grpc_subchannel **subchannels, + size_t num_subchannels); + +#endif diff --git a/src/core/client_config/resolver.h b/src/core/client_config/resolver.h index 7ff955ec6e6..13d48bc5721 100644 --- a/src/core/client_config/resolver.h +++ b/src/core/client_config/resolver.h @@ -52,7 +52,8 @@ struct grpc_resolver_vtable { void (*unref)(grpc_resolver *resolver); void (*shutdown)(grpc_resolver *resolver); void (*channel_saw_error)(grpc_resolver *resolver, - struct sockaddr *failing_address); + struct sockaddr *failing_address, + int failing_address_len); void (*next)(grpc_resolver *resolver, grpc_client_config **target_config, grpc_iomgr_closure *on_complete); }; diff --git a/src/core/client_config/resolver_factory.h b/src/core/client_config/resolver_factory.h index 701910d71ae..c5d85499c6e 100644 --- a/src/core/client_config/resolver_factory.h +++ b/src/core/client_config/resolver_factory.h @@ -34,31 +34,34 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_FACTORY_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_FACTORY_H -#include "src/core/client_config/client_config.h" -#include "src/core/iomgr/iomgr.h" -#include "src/core/iomgr/sockaddr.h" +#include "src/core/client_config/resolver.h" +#include "src/core/client_config/subchannel_factory.h" +#include "src/core/client_config/uri_parser.h" -typedef struct grpc_resolver grpc_resolver; -typedef struct grpc_resolver_vtable grpc_resolver_vtable; +typedef struct grpc_resolver_factory grpc_resolver_factory; +typedef struct grpc_resolver_factory_vtable grpc_resolver_factory_vtable; /** grpc_resolver provides grpc_client_config objects to grpc_channel objects */ -struct grpc_resolver { - const grpc_resolver_vtable *vtable; +struct grpc_resolver_factory { + const grpc_resolver_factory_vtable *vtable; }; struct grpc_resolver_factory_vtable { - void (*ref)(grpc_resolver *resolver); - void (*unref)(grpc_resolver *resolver); + void (*ref)(grpc_resolver_factory *factory); + void (*unref)(grpc_resolver_factory *factory); - grpc_resolver *(*create_resolver)(const char *name); + grpc_resolver *(*create_resolver)( + grpc_resolver_factory *factory, grpc_uri *uri, + grpc_subchannel_factory *subchannel_factory); }; -void grpc_resolver_factory_ref(grpc_resolver *resolver); -void grpc_resolver_factory_unref(grpc_resolver *resolver); +void grpc_resolver_factory_ref(grpc_resolver_factory *resolver); +void grpc_resolver_factory_unref(grpc_resolver_factory *resolver); /** Create a resolver instance for a name */ grpc_resolver *grpc_resolver_factory_create_resolver( - grpc_resolver_factory *resolver, const char *name); + grpc_resolver_factory *factory, grpc_uri *uri, + grpc_subchannel_factory *subchannel_factory); #endif /* GRPC_INTERNAL_CORE_CONFIG_RESOLVER_FACTORY_H */ diff --git a/src/core/client_config/resolver_registry.c b/src/core/client_config/resolver_registry.c new file mode 100644 index 00000000000..770d4aca8e9 --- /dev/null +++ b/src/core/client_config/resolver_registry.c @@ -0,0 +1,102 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/resolver_registry.h" + +#include + +#include +#include +#include + +#define MAX_RESOLVERS 10 + +typedef struct { + char *scheme; + grpc_resolver_factory *factory; +} registered_resolver; + +static registered_resolver all_of_the_resolvers[MAX_RESOLVERS]; +static int number_of_resolvers = 0; + +void grpc_resolver_registry_init(grpc_resolver_factory *r) { + number_of_resolvers = 0; + grpc_register_resolver_type("default-grpc-resolver", r); +} + +void grpc_resolver_registry_shutdown(void) { + int i; + for (i = 0; i < number_of_resolvers; i++) { + gpr_free(all_of_the_resolvers[i].scheme); + grpc_resolver_factory_unref(all_of_the_resolvers[i].factory); + } +} + +void grpc_register_resolver_type(const char *scheme, + grpc_resolver_factory *factory) { + int i; + for (i = 0; i < number_of_resolvers; i++) { + GPR_ASSERT(0 != strcmp(scheme, all_of_the_resolvers[i].scheme)); + } + GPR_ASSERT(number_of_resolvers != MAX_RESOLVERS); + all_of_the_resolvers[number_of_resolvers].scheme = gpr_strdup(scheme); + grpc_resolver_factory_ref(factory); + all_of_the_resolvers[number_of_resolvers].factory = factory; + number_of_resolvers++; +} + +grpc_resolver *grpc_resolver_create( + const char *name, grpc_subchannel_factory *subchannel_factory) { + grpc_uri *uri; + int i; + char *tmp; + grpc_resolver *resolver = NULL; + if (grpc_has_scheme(name)) { + uri = grpc_uri_parse(name); + if (!uri) { + return NULL; + } + for (i = 0; i < number_of_resolvers; i++) { + if (0 == strcmp(all_of_the_resolvers[i].scheme, uri->scheme)) { + grpc_resolver_factory_create_resolver(all_of_the_resolvers[i].factory, + uri, subchannel_factory); + } + } + } else { + gpr_asprintf(&tmp, "default-grpc-resolver:%s", name); + GPR_ASSERT(grpc_has_scheme(tmp)); + resolver = grpc_resolver_create(tmp, subchannel_factory); + gpr_free(tmp); + } + return resolver; +} diff --git a/src/core/client_config/resolver_registry.h b/src/core/client_config/resolver_registry.h new file mode 100644 index 00000000000..53335172da0 --- /dev/null +++ b/src/core/client_config/resolver_registry.h @@ -0,0 +1,54 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H + +#include "src/core/client_config/resolver_factory.h" + +void grpc_resolver_registry_init(grpc_resolver_factory *default_resolver); +void grpc_resolver_registry_shutdown(void); + +/** Register a resolver type. + URI's of \a scheme will be resolved with the given resolver. + If \a priority is greater than zero, then the resolver will be eligible + to resolve names that are passed in with no scheme. Higher priority + resolvers will be tried before lower priority schemes. */ +void grpc_register_resolver_type(const char *scheme, + grpc_resolver_factory *factory); + +/** Create a resolver given a \a uri string (with an optional scheme prefix) */ +grpc_resolver *grpc_resolver_create( + const char *name, grpc_subchannel_factory *subchannel_factory); + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H */ diff --git a/src/core/client_config/resolvers/dns_resolver.c b/src/core/client_config/resolvers/dns_resolver.c index 187ff26466e..95f38ecab75 100644 --- a/src/core/client_config/resolvers/dns_resolver.c +++ b/src/core/client_config/resolvers/dns_resolver.c @@ -33,4 +33,229 @@ #include "src/core/client_config/resolvers/dns_resolver.h" - \ No newline at end of file +#include + +#include +#include + +#include "src/core/iomgr/resolve_address.h" +#include "src/core/support/string.h" + +typedef struct { + /** base class: must be first */ + grpc_resolver base; + /** refcount */ + gpr_refcount refs; + /** name to resolve */ + char *name; + /** default port to use */ + char *default_port; + /** subchannel factory */ + grpc_subchannel_factory *subchannel_factory; + /** load balancing policy factory */ + grpc_lb_policy *(*lb_policy_factory)(grpc_subchannel **subchannels, + size_t num_subchannels); + + /** mutex guarding the rest of the state */ + gpr_mu mu; + /** are we currently resolving? */ + int resolving; + /** which version of resolved_config have we published? */ + int published_version; + /** which version of resolved_config is current? */ + int resolved_version; + /** pending next completion, or NULL */ + grpc_iomgr_closure *next_completion; + /** target config address for next completion */ + grpc_client_config **target_config; + /** current (fully resolved) config */ + grpc_client_config *resolved_config; +} dns_resolver; + +static void dns_destroy(dns_resolver *r); + +static void dns_start_resolving_locked(dns_resolver *r); +static void dns_maybe_finish_next_locked(dns_resolver *r); + +static void dns_ref(grpc_resolver *r); +static void dns_unref(grpc_resolver *r); +static void dns_shutdown(grpc_resolver *r); +static void dns_channel_saw_error(grpc_resolver *r, + struct sockaddr *failing_address, + int failing_address_len); +static void dns_next(grpc_resolver *r, grpc_client_config **target_config, + grpc_iomgr_closure *on_complete); + +static const grpc_resolver_vtable dns_resolver_vtable = { + dns_ref, dns_unref, dns_shutdown, dns_channel_saw_error, dns_next}; + +static void dns_ref(grpc_resolver *resolver) { + dns_resolver *r = (dns_resolver *)resolver; + gpr_ref(&r->refs); +} + +static void dns_unref(grpc_resolver *resolver) { + dns_resolver *r = (dns_resolver *)resolver; + if (gpr_unref(&r->refs)) { + dns_destroy(r); + } +} + +static void dns_shutdown(grpc_resolver *resolver) { + dns_resolver *r = (dns_resolver *)resolver; + gpr_mu_lock(&r->mu); + if (r->next_completion != NULL) { + *r->target_config = NULL; + /* TODO(ctiller): add delayed callback */ + grpc_iomgr_add_callback(r->next_completion); + r->next_completion = NULL; + } + gpr_mu_unlock(&r->mu); +} + +static void dns_channel_saw_error(grpc_resolver *resolver, struct sockaddr *sa, + int len) { + dns_resolver *r = (dns_resolver *)resolver; + gpr_mu_lock(&r->mu); + if (!r->resolving) { + dns_start_resolving_locked(r); + } + gpr_mu_unlock(&r->mu); +} + +static void dns_next(grpc_resolver *resolver, + grpc_client_config **target_config, + grpc_iomgr_closure *on_complete) { + dns_resolver *r = (dns_resolver *)resolver; + gpr_mu_lock(&r->mu); + GPR_ASSERT(!r->next_completion); + r->next_completion = on_complete; + r->target_config = target_config; + if (r->resolved_version == 0 && !r->resolving) { + dns_start_resolving_locked(r); + } else { + dns_maybe_finish_next_locked(r); + } + gpr_mu_unlock(&r->mu); +} + +static void dns_on_resolved(void *arg, grpc_resolved_addresses *addresses) { + dns_resolver *r = arg; + grpc_client_config *config = NULL; + grpc_subchannel **subchannels; + grpc_subchannel_args args; + size_t i; + if (addresses) { + config = grpc_client_config_create(); + subchannels = gpr_malloc(sizeof(grpc_subchannel *) * addresses->naddrs); + for (i = 0; i < addresses->naddrs; i++) { + memset(&args, 0, sizeof(args)); + args.addr = (struct sockaddr *)(addresses->addrs[i].addr); + args.addr_len = addresses->addrs[i].len; + subchannels[i] = grpc_subchannel_factory_create_subchannel( + r->subchannel_factory, &args); + } + grpc_client_config_set_lb_policy( + config, r->lb_policy_factory(subchannels, addresses->naddrs)); + } + gpr_mu_lock(&r->mu); + if (r->resolved_config) { + grpc_client_config_unref(r->resolved_config); + } + r->resolved_config = config; + r->resolved_version++; + dns_maybe_finish_next_locked(r); + gpr_mu_unlock(&r->mu); +} + +static void dns_start_resolving_locked(dns_resolver *r) { + dns_ref(&r->base); + r->resolving = 1; + grpc_resolve_address(r->name, r->default_port, dns_on_resolved, r); +} + +static void dns_maybe_finish_next_locked(dns_resolver *r) { + if (r->next_completion != NULL && + r->resolved_version != r->published_version) { + grpc_iomgr_add_callback(r->next_completion); + r->next_completion = NULL; + r->published_version = r->resolved_version; + } +} + +static void dns_destroy(dns_resolver *r) { + gpr_mu_destroy(&r->mu); + grpc_subchannel_factory_unref(r->subchannel_factory); + gpr_free(r->name); + gpr_free(r->default_port); + gpr_free(r); +} + +static grpc_resolver *dns_create(grpc_uri *uri, const char *default_port, + grpc_subchannel_factory *subchannel_factory) { + dns_resolver *r; + const char *path = uri->path; + + if (0 != strcmp(uri->authority, "")) { + gpr_log(GPR_ERROR, "authority based uri's not supported"); + return NULL; + } + + if (path[0] == '/') ++path; + + r = gpr_malloc(sizeof(dns_resolver)); + memset(r, 0, sizeof(*r)); + gpr_ref_init(&r->refs, 1); + gpr_mu_init(&r->mu); + r->base.vtable = &dns_resolver_vtable; + r->name = gpr_strdup(path); + r->default_port = gpr_strdup(default_port); + r->subchannel_factory = subchannel_factory; + grpc_subchannel_factory_ref(subchannel_factory); + return &r->base; +} + +/* + * FACTORY + */ + +typedef struct { + /** base: must be first */ + grpc_resolver_factory base; + /** ref count */ + gpr_refcount refs; + /** default port */ + char *default_port; +} dns_resolver_factory; + +static void dns_factory_ref(grpc_resolver_factory *factory) { + dns_resolver_factory *f = (dns_resolver_factory *)factory; + gpr_ref(&f->refs); +} + +static void dns_factory_unref(grpc_resolver_factory *factory) { + dns_resolver_factory *f = (dns_resolver_factory *)factory; + if (gpr_unref(&f->refs)) { + gpr_free(f->default_port); + gpr_free(f); + } +} + +static grpc_resolver *dns_factory_create_resolver( + grpc_resolver_factory *factory, grpc_uri *uri, + grpc_subchannel_factory *subchannel_factory) { + dns_resolver_factory *f = (dns_resolver_factory *)factory; + return dns_create(uri, f->default_port, subchannel_factory); +} + +static const grpc_resolver_factory_vtable dns_factory_vtable = { + dns_factory_ref, dns_factory_unref, dns_factory_create_resolver}; + +grpc_resolver_factory *grpc_dns_resolver_factory_create( + const char *default_port) { + dns_resolver_factory *f = gpr_malloc(sizeof(*f)); + memset(f, 0, sizeof(*f)); + f->base.vtable = &dns_factory_vtable; + f->default_port = gpr_strdup(default_port); + return &f->base; +} diff --git a/src/core/client_config/resolvers/dns_resolver.h b/src/core/client_config/resolvers/dns_resolver.h index fc32baa15b6..9881448fd8e 100644 --- a/src/core/client_config/resolvers/dns_resolver.h +++ b/src/core/client_config/resolvers/dns_resolver.h @@ -34,7 +34,10 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H +#include "src/core/client_config/resolver_factory.h" + /** Create a dns resolver for \a name */ -grpc_resolver *grpc_dns_resolver_create(const char *name); +grpc_resolver_factory *grpc_dns_resolver_factory_create( + const char *default_port); -#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H */ +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H */ diff --git a/src/core/client_config/subchannel_factory.h b/src/core/client_config/subchannel_factory.h index 26fa3297974..cbe984f428a 100644 --- a/src/core/client_config/subchannel_factory.h +++ b/src/core/client_config/subchannel_factory.h @@ -57,6 +57,7 @@ struct grpc_subchannel_args { const grpc_channel_args *args; /** Address to connect to */ struct sockaddr *addr; + size_t addr_len; }; struct grpc_subchannel_factory_vtable { @@ -70,7 +71,7 @@ void grpc_subchannel_factory_ref(grpc_subchannel_factory *factory); void grpc_subchannel_factory_unref(grpc_subchannel_factory *factory); /** Create a new grpc_subchannel */ -void grpc_subchannel_factory_create_subchannel(grpc_subchannel_factory *factory, - grpc_subchannel_args *args); +grpc_subchannel *grpc_subchannel_factory_create_subchannel( + grpc_subchannel_factory *factory, grpc_subchannel_args *args); #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H */ diff --git a/src/core/client_config/uri_parser.c b/src/core/client_config/uri_parser.c new file mode 100644 index 00000000000..24dfaae4970 --- /dev/null +++ b/src/core/client_config/uri_parser.c @@ -0,0 +1,169 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/uri_parser.h" + +#include + +#include +#include +#include + +static grpc_uri *bad_uri(const char *uri_text, int pos, const char *section) { + char *line_prefix; + int pfx_len; + + gpr_asprintf(&line_prefix, "bad uri.%s: '", section); + pfx_len = strlen(line_prefix) + pos; + gpr_log(GPR_ERROR, "%s%s'", line_prefix, uri_text); + gpr_free(line_prefix); + + line_prefix = gpr_malloc(pfx_len + 1); + memset(line_prefix, ' ', pfx_len); + line_prefix[pfx_len] = 0; + gpr_log(GPR_ERROR, "%s^ here", line_prefix); + gpr_free(line_prefix); + + return NULL; +} + +static char *copy_fragment(const char *src, int begin, int end) { + char *out = gpr_malloc(end - begin + 1); + memcpy(out, src + begin, end - begin); + out[end - begin] = 0; + return out; +} + +int grpc_has_scheme(const char *uri_text) { + int scheme_begin = 0; + int scheme_end = -1; + int i; + + for (i = scheme_begin; uri_text[i] != 0; i++) { + if (uri_text[i] == ':') { + scheme_end = i; + break; + } + if (uri_text[i] >= 'a' && uri_text[i] <= 'z') continue; + if (uri_text[i] >= 'A' && uri_text[i] <= 'Z') continue; + if (i != scheme_begin) { + if (uri_text[i] >= '0' && uri_text[i] <= '9') continue; + if (uri_text[i] == '+') continue; + if (uri_text[i] == '-') continue; + if (uri_text[i] == '.') continue; + } + break; + } + + return scheme_end != -1; +} + +grpc_uri *grpc_uri_parse(const char *uri_text) { + grpc_uri *uri; + int scheme_begin = 0; + int scheme_end = -1; + int authority_begin = -1; + int authority_end = -1; + int path_begin = -1; + int path_end = -1; + int i; + + for (i = scheme_begin; uri_text[i] != 0; i++) { + if (uri_text[i] == ':') { + scheme_end = i; + break; + } + if (uri_text[i] >= 'a' && uri_text[i] <= 'z') continue; + if (uri_text[i] >= 'A' && uri_text[i] <= 'Z') continue; + if (i != scheme_begin) { + if (uri_text[i] >= '0' && uri_text[i] <= '9') continue; + if (uri_text[i] == '+') continue; + if (uri_text[i] == '-') continue; + if (uri_text[i] == '.') continue; + } + break; + } + if (scheme_end == -1) { + return bad_uri(uri_text, i, "scheme"); + } + + if (uri_text[scheme_end + 1] == '/' && uri_text[scheme_end + 2] == '/') { + authority_begin = scheme_end + 3; + for (i = authority_begin; uri_text[i] != 0; i++) { + if (uri_text[i] == '/') { + authority_end = i; + } + if (uri_text[i] == '?') { + return bad_uri(uri_text, i, "query_not_supported"); + } + if (uri_text[i] == '#') { + return bad_uri(uri_text, i, "fragment_not_supported"); + } + } + if (authority_end == -1 && uri_text[i] == 0) { + authority_end = i; + } + if (authority_end == -1) { + return bad_uri(uri_text, i, "authority"); + } + /* TODO(ctiller): parse the authority correctly */ + path_begin = authority_end; + } else { + path_begin = scheme_end + 1; + } + + for (i = path_begin; uri_text[i] != 0; i++) { + if (uri_text[i] == '?') { + return bad_uri(uri_text, i, "query_not_supported"); + } + if (uri_text[i] == '#') { + return bad_uri(uri_text, i, "fragment_not_supported"); + } + } + path_end = i; + + uri = gpr_malloc(sizeof(*uri)); + memset(uri, 0, sizeof(*uri)); + uri->scheme = copy_fragment(uri_text, scheme_begin, scheme_end); + uri->authority = copy_fragment(uri_text, authority_begin, authority_end); + uri->path = copy_fragment(uri_text, path_begin, path_end); + + return uri; +} + +void grpc_uri_destroy(grpc_uri *uri) { + gpr_free(uri->scheme); + gpr_free(uri->authority); + gpr_free(uri->path); + gpr_free(uri); +} diff --git a/src/core/client_config/uri_parser.h b/src/core/client_config/uri_parser.h new file mode 100644 index 00000000000..0e21d568a9c --- /dev/null +++ b/src/core/client_config/uri_parser.h @@ -0,0 +1,52 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_URI_PARSER_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_URI_PARSER_H + +typedef struct { + char *scheme; + char *authority; + char *path; +} grpc_uri; + +/** parse a uri, return NULL on failure */ +grpc_uri *grpc_uri_parse(const char *uri_text); + +/** return 1 if uri_text has something that is likely a scheme, 0 otherwise */ +int grpc_has_scheme(const char *uri_text); + +/** destroy a uri */ +void grpc_uri_destroy(grpc_uri *uri); + +#endif diff --git a/test/core/client_config/uri_parser_test.c b/test/core/client_config/uri_parser_test.c new file mode 100644 index 00000000000..1dfbcfba6b9 --- /dev/null +++ b/test/core/client_config/uri_parser_test.c @@ -0,0 +1,68 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/uri_parser.h" + +#include + +#include + +#include "test/core/util/test_config.h" + +static void test_succeeds(const char *uri_text, const char *scheme, + const char *authority, const char *path) { + grpc_uri *uri = grpc_uri_parse(uri_text); + GPR_ASSERT(uri); + GPR_ASSERT(0 == strcmp(scheme, uri->scheme)); + GPR_ASSERT(0 == strcmp(authority, uri->authority)); + GPR_ASSERT(0 == strcmp(path, uri->path)); + grpc_uri_destroy(uri); +} + +static void test_fails(const char *uri_text) { + GPR_ASSERT(NULL == grpc_uri_parse(uri_text)); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + test_succeeds("http://www.google.com", "http", "www.google.com", ""); + test_succeeds("dns:///foo", "dns", "", "/foo"); + test_succeeds("http://www.google.com:90", "http", "www.google.com:90", ""); + test_fails("xyz"); + test_fails("http://www.google.com?why-are-you-using-queries"); + + GPR_ASSERT(grpc_has_scheme("http:adfhadf")); + GPR_ASSERT(grpc_has_scheme("http://adfhadf")); + GPR_ASSERT(!grpc_has_scheme("adfhadf")); + return 0; +} diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 023855ed5e6..cf72f7ada54 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -760,7 +760,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = include/grpc/grpc_security.h include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h include/grpc/grpc.h include/grpc/status.h include/grpc/census.h src/core/httpcli/format_request.h src/core/httpcli/httpcli.h src/core/httpcli/httpcli_security_connector.h src/core/httpcli/parser.h src/core/security/auth_filters.h src/core/security/base64.h src/core/security/credentials.h src/core/security/json_token.h src/core/security/secure_endpoint.h src/core/security/secure_transport_setup.h src/core/security/security_connector.h src/core/security/security_context.h src/core/tsi/fake_transport_security.h src/core/tsi/ssl_transport_security.h src/core/tsi/transport_security.h src/core/tsi/transport_security_interface.h src/core/census/grpc_context.h src/core/channel/census_filter.h src/core/channel/channel_args.h src/core/channel/channel_stack.h src/core/channel/child_channel.h src/core/channel/client_channel.h src/core/channel/client_setup.h src/core/channel/connected_channel.h src/core/channel/context.h src/core/channel/http_client_filter.h src/core/channel/http_server_filter.h src/core/channel/noop_filter.h src/core/client_config/client_config.h src/core/client_config/lb_policy.h src/core/client_config/resolver.h src/core/client_config/resolver_factory.h src/core/client_config/subchannel.h src/core/client_config/subchannel_factory.h src/core/compression/message_compress.h src/core/debug/trace.h src/core/iomgr/alarm.h src/core/iomgr/alarm_heap.h src/core/iomgr/alarm_internal.h src/core/iomgr/endpoint.h src/core/iomgr/endpoint_pair.h src/core/iomgr/fd_posix.h src/core/iomgr/iocp_windows.h src/core/iomgr/iomgr.h src/core/iomgr/iomgr_internal.h src/core/iomgr/iomgr_posix.h src/core/iomgr/pollset.h src/core/iomgr/pollset_kick_posix.h src/core/iomgr/pollset_posix.h src/core/iomgr/pollset_set.h src/core/iomgr/pollset_set_posix.h src/core/iomgr/pollset_set_windows.h src/core/iomgr/pollset_windows.h src/core/iomgr/resolve_address.h src/core/iomgr/sockaddr.h src/core/iomgr/sockaddr_posix.h src/core/iomgr/sockaddr_utils.h src/core/iomgr/sockaddr_win32.h src/core/iomgr/socket_utils_posix.h src/core/iomgr/socket_windows.h src/core/iomgr/tcp_client.h src/core/iomgr/tcp_posix.h src/core/iomgr/tcp_server.h src/core/iomgr/tcp_windows.h src/core/iomgr/time_averaged_stats.h src/core/iomgr/wakeup_fd_pipe.h src/core/iomgr/wakeup_fd_posix.h src/core/json/json.h src/core/json/json_common.h src/core/json/json_reader.h src/core/json/json_writer.h src/core/profiling/timers.h src/core/profiling/timers_preciseclock.h src/core/surface/byte_buffer_queue.h src/core/surface/call.h src/core/surface/channel.h src/core/surface/client.h src/core/surface/completion_queue.h src/core/surface/event_string.h src/core/surface/init.h src/core/surface/server.h src/core/surface/surface_trace.h src/core/transport/chttp2/alpn.h src/core/transport/chttp2/bin_encoder.h src/core/transport/chttp2/frame.h src/core/transport/chttp2/frame_data.h src/core/transport/chttp2/frame_goaway.h src/core/transport/chttp2/frame_ping.h src/core/transport/chttp2/frame_rst_stream.h src/core/transport/chttp2/frame_settings.h src/core/transport/chttp2/frame_window_update.h src/core/transport/chttp2/hpack_parser.h src/core/transport/chttp2/hpack_table.h src/core/transport/chttp2/http2_errors.h src/core/transport/chttp2/huffsyms.h src/core/transport/chttp2/status_conversion.h src/core/transport/chttp2/stream_encoder.h src/core/transport/chttp2/stream_map.h src/core/transport/chttp2/timeout_encoding.h src/core/transport/chttp2/varint.h src/core/transport/chttp2_transport.h src/core/transport/metadata.h src/core/transport/stream_op.h src/core/transport/transport.h src/core/transport/transport_impl.h src/core/census/context.h src/core/httpcli/format_request.c src/core/httpcli/httpcli.c src/core/httpcli/httpcli_security_connector.c src/core/httpcli/parser.c src/core/security/base64.c src/core/security/client_auth_filter.c src/core/security/credentials.c src/core/security/credentials_metadata.c src/core/security/credentials_posix.c src/core/security/credentials_win32.c src/core/security/google_default_credentials.c src/core/security/json_token.c src/core/security/secure_endpoint.c src/core/security/secure_transport_setup.c src/core/security/security_connector.c src/core/security/security_context.c src/core/security/server_auth_filter.c src/core/security/server_secure_chttp2.c src/core/surface/init_secure.c src/core/surface/secure_channel_create.c src/core/tsi/fake_transport_security.c src/core/tsi/ssl_transport_security.c src/core/tsi/transport_security.c src/core/census/grpc_context.c src/core/channel/channel_args.c src/core/channel/channel_stack.c src/core/channel/child_channel.c src/core/channel/client_channel.c src/core/channel/client_setup.c src/core/channel/connected_channel.c src/core/channel/http_client_filter.c src/core/channel/http_server_filter.c src/core/channel/noop_filter.c src/core/client_config/client_config.c src/core/client_config/lb_policy.c src/core/client_config/resolver.c src/core/client_config/resolver_factory.c src/core/client_config/subchannel.c src/core/client_config/subchannel_factory.c src/core/compression/algorithm.c src/core/compression/message_compress.c src/core/debug/trace.c src/core/iomgr/alarm.c src/core/iomgr/alarm_heap.c src/core/iomgr/endpoint.c src/core/iomgr/endpoint_pair_posix.c src/core/iomgr/endpoint_pair_windows.c src/core/iomgr/fd_posix.c src/core/iomgr/iocp_windows.c src/core/iomgr/iomgr.c src/core/iomgr/iomgr_posix.c src/core/iomgr/iomgr_windows.c src/core/iomgr/pollset_kick_posix.c src/core/iomgr/pollset_multipoller_with_epoll.c src/core/iomgr/pollset_multipoller_with_poll_posix.c src/core/iomgr/pollset_posix.c src/core/iomgr/pollset_set_posix.c src/core/iomgr/pollset_set_windows.c src/core/iomgr/pollset_windows.c src/core/iomgr/resolve_address_posix.c src/core/iomgr/resolve_address_windows.c src/core/iomgr/sockaddr_utils.c src/core/iomgr/socket_utils_common_posix.c src/core/iomgr/socket_utils_linux.c src/core/iomgr/socket_utils_posix.c src/core/iomgr/socket_windows.c src/core/iomgr/tcp_client_posix.c src/core/iomgr/tcp_client_windows.c src/core/iomgr/tcp_posix.c src/core/iomgr/tcp_server_posix.c src/core/iomgr/tcp_server_windows.c src/core/iomgr/tcp_windows.c src/core/iomgr/time_averaged_stats.c src/core/iomgr/wakeup_fd_eventfd.c src/core/iomgr/wakeup_fd_nospecial.c src/core/iomgr/wakeup_fd_pipe.c src/core/iomgr/wakeup_fd_posix.c src/core/json/json.c src/core/json/json_reader.c src/core/json/json_string.c src/core/json/json_writer.c src/core/profiling/basic_timers.c src/core/profiling/stap_timers.c src/core/surface/byte_buffer.c src/core/surface/byte_buffer_queue.c src/core/surface/byte_buffer_reader.c src/core/surface/call.c src/core/surface/call_details.c src/core/surface/call_log_batch.c src/core/surface/channel.c src/core/surface/channel_create.c src/core/surface/client.c src/core/surface/completion_queue.c src/core/surface/event_string.c src/core/surface/init.c src/core/surface/lame_client.c src/core/surface/metadata_array.c src/core/surface/server.c src/core/surface/server_chttp2.c src/core/surface/server_create.c src/core/surface/surface_trace.c src/core/transport/chttp2/alpn.c src/core/transport/chttp2/bin_encoder.c src/core/transport/chttp2/frame_data.c src/core/transport/chttp2/frame_goaway.c src/core/transport/chttp2/frame_ping.c src/core/transport/chttp2/frame_rst_stream.c src/core/transport/chttp2/frame_settings.c src/core/transport/chttp2/frame_window_update.c src/core/transport/chttp2/hpack_parser.c src/core/transport/chttp2/hpack_table.c src/core/transport/chttp2/huffsyms.c src/core/transport/chttp2/status_conversion.c src/core/transport/chttp2/stream_encoder.c src/core/transport/chttp2/stream_map.c src/core/transport/chttp2/timeout_encoding.c src/core/transport/chttp2/varint.c src/core/transport/chttp2_transport.c src/core/transport/metadata.c src/core/transport/stream_op.c src/core/transport/transport.c src/core/transport/transport_op_string.c src/core/census/context.c src/core/census/initialize.c include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_win32.h include/grpc/support/cancellable_platform.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/histogram.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_win32.h include/grpc/support/port_platform.h include/grpc/support/slice.h include/grpc/support/slice_buffer.h include/grpc/support/string_util.h include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h include/grpc/support/sync_win32.h include/grpc/support/thd.h include/grpc/support/time.h include/grpc/support/tls.h include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h include/grpc/support/useful.h src/core/support/env.h src/core/support/file.h src/core/support/murmur_hash.h src/core/support/string.h src/core/support/string_win32.h src/core/support/thd_internal.h src/core/support/alloc.c src/core/support/cancellable.c src/core/support/cmdline.c src/core/support/cpu_iphone.c src/core/support/cpu_linux.c src/core/support/cpu_posix.c src/core/support/cpu_windows.c src/core/support/env_linux.c src/core/support/env_posix.c src/core/support/env_win32.c src/core/support/file.c src/core/support/file_posix.c src/core/support/file_win32.c src/core/support/histogram.c src/core/support/host_port.c src/core/support/log.c src/core/support/log_android.c src/core/support/log_linux.c src/core/support/log_posix.c src/core/support/log_win32.c src/core/support/murmur_hash.c src/core/support/slice.c src/core/support/slice_buffer.c src/core/support/string.c src/core/support/string_posix.c src/core/support/string_win32.c src/core/support/subprocess_posix.c src/core/support/sync.c src/core/support/sync_posix.c src/core/support/sync_win32.c src/core/support/thd.c src/core/support/thd_posix.c src/core/support/thd_win32.c src/core/support/time.c src/core/support/time_posix.c src/core/support/time_win32.c src/core/support/tls_pthread.c +INPUT = include/grpc/grpc_security.h include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h include/grpc/grpc.h include/grpc/status.h include/grpc/census.h src/core/httpcli/format_request.h src/core/httpcli/httpcli.h src/core/httpcli/httpcli_security_connector.h src/core/httpcli/parser.h src/core/security/auth_filters.h src/core/security/base64.h src/core/security/credentials.h src/core/security/json_token.h src/core/security/secure_endpoint.h src/core/security/secure_transport_setup.h src/core/security/security_connector.h src/core/security/security_context.h src/core/tsi/fake_transport_security.h src/core/tsi/ssl_transport_security.h src/core/tsi/transport_security.h src/core/tsi/transport_security_interface.h src/core/census/grpc_context.h src/core/channel/census_filter.h src/core/channel/channel_args.h src/core/channel/channel_stack.h src/core/channel/child_channel.h src/core/channel/client_channel.h src/core/channel/client_setup.h src/core/channel/connected_channel.h src/core/channel/context.h src/core/channel/http_client_filter.h src/core/channel/http_server_filter.h src/core/channel/noop_filter.h src/core/client_config/client_config.h src/core/client_config/lb_policies/pick_first.h src/core/client_config/lb_policy.h src/core/client_config/resolver.h src/core/client_config/resolver_factory.h src/core/client_config/resolver_registry.h src/core/client_config/resolvers/dns_resolver.h src/core/client_config/subchannel.h src/core/client_config/subchannel_factory.h src/core/client_config/uri_parser.h src/core/compression/message_compress.h src/core/debug/trace.h src/core/iomgr/alarm.h src/core/iomgr/alarm_heap.h src/core/iomgr/alarm_internal.h src/core/iomgr/endpoint.h src/core/iomgr/endpoint_pair.h src/core/iomgr/fd_posix.h src/core/iomgr/iocp_windows.h src/core/iomgr/iomgr.h src/core/iomgr/iomgr_internal.h src/core/iomgr/iomgr_posix.h src/core/iomgr/pollset.h src/core/iomgr/pollset_kick_posix.h src/core/iomgr/pollset_posix.h src/core/iomgr/pollset_set.h src/core/iomgr/pollset_set_posix.h src/core/iomgr/pollset_set_windows.h src/core/iomgr/pollset_windows.h src/core/iomgr/resolve_address.h src/core/iomgr/sockaddr.h src/core/iomgr/sockaddr_posix.h src/core/iomgr/sockaddr_utils.h src/core/iomgr/sockaddr_win32.h src/core/iomgr/socket_utils_posix.h src/core/iomgr/socket_windows.h src/core/iomgr/tcp_client.h src/core/iomgr/tcp_posix.h src/core/iomgr/tcp_server.h src/core/iomgr/tcp_windows.h src/core/iomgr/time_averaged_stats.h src/core/iomgr/wakeup_fd_pipe.h src/core/iomgr/wakeup_fd_posix.h src/core/json/json.h src/core/json/json_common.h src/core/json/json_reader.h src/core/json/json_writer.h src/core/profiling/timers.h src/core/profiling/timers_preciseclock.h src/core/surface/byte_buffer_queue.h src/core/surface/call.h src/core/surface/channel.h src/core/surface/client.h src/core/surface/completion_queue.h src/core/surface/event_string.h src/core/surface/init.h src/core/surface/server.h src/core/surface/surface_trace.h src/core/transport/chttp2/alpn.h src/core/transport/chttp2/bin_encoder.h src/core/transport/chttp2/frame.h src/core/transport/chttp2/frame_data.h src/core/transport/chttp2/frame_goaway.h src/core/transport/chttp2/frame_ping.h src/core/transport/chttp2/frame_rst_stream.h src/core/transport/chttp2/frame_settings.h src/core/transport/chttp2/frame_window_update.h src/core/transport/chttp2/hpack_parser.h src/core/transport/chttp2/hpack_table.h src/core/transport/chttp2/http2_errors.h src/core/transport/chttp2/huffsyms.h src/core/transport/chttp2/status_conversion.h src/core/transport/chttp2/stream_encoder.h src/core/transport/chttp2/stream_map.h src/core/transport/chttp2/timeout_encoding.h src/core/transport/chttp2/varint.h src/core/transport/chttp2_transport.h src/core/transport/metadata.h src/core/transport/stream_op.h src/core/transport/transport.h src/core/transport/transport_impl.h src/core/census/context.h src/core/httpcli/format_request.c src/core/httpcli/httpcli.c src/core/httpcli/httpcli_security_connector.c src/core/httpcli/parser.c src/core/security/base64.c src/core/security/client_auth_filter.c src/core/security/credentials.c src/core/security/credentials_metadata.c src/core/security/credentials_posix.c src/core/security/credentials_win32.c src/core/security/google_default_credentials.c src/core/security/json_token.c src/core/security/secure_endpoint.c src/core/security/secure_transport_setup.c src/core/security/security_connector.c src/core/security/security_context.c src/core/security/server_auth_filter.c src/core/security/server_secure_chttp2.c src/core/surface/init_secure.c src/core/surface/secure_channel_create.c src/core/tsi/fake_transport_security.c src/core/tsi/ssl_transport_security.c src/core/tsi/transport_security.c src/core/census/grpc_context.c src/core/channel/channel_args.c src/core/channel/channel_stack.c src/core/channel/child_channel.c src/core/channel/client_channel.c src/core/channel/client_setup.c src/core/channel/connected_channel.c src/core/channel/http_client_filter.c src/core/channel/http_server_filter.c src/core/channel/noop_filter.c src/core/client_config/client_config.c src/core/client_config/lb_policies/pick_first.c src/core/client_config/lb_policy.c src/core/client_config/resolver.c src/core/client_config/resolver_factory.c src/core/client_config/resolver_registry.c src/core/client_config/resolvers/dns_resolver.c src/core/client_config/subchannel.c src/core/client_config/subchannel_factory.c src/core/client_config/uri_parser.c src/core/compression/algorithm.c src/core/compression/message_compress.c src/core/debug/trace.c src/core/iomgr/alarm.c src/core/iomgr/alarm_heap.c src/core/iomgr/endpoint.c src/core/iomgr/endpoint_pair_posix.c src/core/iomgr/endpoint_pair_windows.c src/core/iomgr/fd_posix.c src/core/iomgr/iocp_windows.c src/core/iomgr/iomgr.c src/core/iomgr/iomgr_posix.c src/core/iomgr/iomgr_windows.c src/core/iomgr/pollset_kick_posix.c src/core/iomgr/pollset_multipoller_with_epoll.c src/core/iomgr/pollset_multipoller_with_poll_posix.c src/core/iomgr/pollset_posix.c src/core/iomgr/pollset_set_posix.c src/core/iomgr/pollset_set_windows.c src/core/iomgr/pollset_windows.c src/core/iomgr/resolve_address_posix.c src/core/iomgr/resolve_address_windows.c src/core/iomgr/sockaddr_utils.c src/core/iomgr/socket_utils_common_posix.c src/core/iomgr/socket_utils_linux.c src/core/iomgr/socket_utils_posix.c src/core/iomgr/socket_windows.c src/core/iomgr/tcp_client_posix.c src/core/iomgr/tcp_client_windows.c src/core/iomgr/tcp_posix.c src/core/iomgr/tcp_server_posix.c src/core/iomgr/tcp_server_windows.c src/core/iomgr/tcp_windows.c src/core/iomgr/time_averaged_stats.c src/core/iomgr/wakeup_fd_eventfd.c src/core/iomgr/wakeup_fd_nospecial.c src/core/iomgr/wakeup_fd_pipe.c src/core/iomgr/wakeup_fd_posix.c src/core/json/json.c src/core/json/json_reader.c src/core/json/json_string.c src/core/json/json_writer.c src/core/profiling/basic_timers.c src/core/profiling/stap_timers.c src/core/surface/byte_buffer.c src/core/surface/byte_buffer_queue.c src/core/surface/byte_buffer_reader.c src/core/surface/call.c src/core/surface/call_details.c src/core/surface/call_log_batch.c src/core/surface/channel.c src/core/surface/channel_create.c src/core/surface/client.c src/core/surface/completion_queue.c src/core/surface/event_string.c src/core/surface/init.c src/core/surface/lame_client.c src/core/surface/metadata_array.c src/core/surface/server.c src/core/surface/server_chttp2.c src/core/surface/server_create.c src/core/surface/surface_trace.c src/core/transport/chttp2/alpn.c src/core/transport/chttp2/bin_encoder.c src/core/transport/chttp2/frame_data.c src/core/transport/chttp2/frame_goaway.c src/core/transport/chttp2/frame_ping.c src/core/transport/chttp2/frame_rst_stream.c src/core/transport/chttp2/frame_settings.c src/core/transport/chttp2/frame_window_update.c src/core/transport/chttp2/hpack_parser.c src/core/transport/chttp2/hpack_table.c src/core/transport/chttp2/huffsyms.c src/core/transport/chttp2/status_conversion.c src/core/transport/chttp2/stream_encoder.c src/core/transport/chttp2/stream_map.c src/core/transport/chttp2/timeout_encoding.c src/core/transport/chttp2/varint.c src/core/transport/chttp2_transport.c src/core/transport/metadata.c src/core/transport/stream_op.c src/core/transport/transport.c src/core/transport/transport_op_string.c src/core/census/context.c src/core/census/initialize.c include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_win32.h include/grpc/support/cancellable_platform.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/histogram.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_win32.h include/grpc/support/port_platform.h include/grpc/support/slice.h include/grpc/support/slice_buffer.h include/grpc/support/string_util.h include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h include/grpc/support/sync_win32.h include/grpc/support/thd.h include/grpc/support/time.h include/grpc/support/tls.h include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h include/grpc/support/useful.h src/core/support/env.h src/core/support/file.h src/core/support/murmur_hash.h src/core/support/string.h src/core/support/string_win32.h src/core/support/thd_internal.h src/core/support/alloc.c src/core/support/cancellable.c src/core/support/cmdline.c src/core/support/cpu_iphone.c src/core/support/cpu_linux.c src/core/support/cpu_posix.c src/core/support/cpu_windows.c src/core/support/env_linux.c src/core/support/env_posix.c src/core/support/env_win32.c src/core/support/file.c src/core/support/file_posix.c src/core/support/file_win32.c src/core/support/histogram.c src/core/support/host_port.c src/core/support/log.c src/core/support/log_android.c src/core/support/log_linux.c src/core/support/log_posix.c src/core/support/log_win32.c src/core/support/murmur_hash.c src/core/support/slice.c src/core/support/slice_buffer.c src/core/support/string.c src/core/support/string_posix.c src/core/support/string_win32.c src/core/support/subprocess_posix.c src/core/support/sync.c src/core/support/sync_posix.c src/core/support/sync_win32.c src/core/support/thd.c src/core/support/thd_posix.c src/core/support/thd_win32.c src/core/support/time.c src/core/support/time_posix.c src/core/support/time_win32.c src/core/support/tls_pthread.c # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 2da8b56d4f9..77db4e3141c 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -541,6 +541,15 @@ "posix" ] }, + { + "flaky": false, + "language": "c", + "name": "uri_parser_test", + "platforms": [ + "windows", + "posix" + ] + }, { "flaky": false, "language": "c++", diff --git a/vsprojects/Grpc.mak b/vsprojects/Grpc.mak index 27f0b3aec30..5d7368ccc64 100644 --- a/vsprojects/Grpc.mak +++ b/vsprojects/Grpc.mak @@ -57,7 +57,7 @@ $(OUT_DIR): build_libs: build_gpr build_gpr_test_util build_grpc build_grpc_test_util build_grpc_test_util_unsecure build_grpc_unsecure Debug\end2end_fixture_chttp2_fake_security.lib Debug\end2end_fixture_chttp2_fullstack.lib Debug\end2end_fixture_chttp2_simple_ssl_fullstack.lib Debug\end2end_fixture_chttp2_simple_ssl_with_oauth2_fullstack.lib Debug\end2end_fixture_chttp2_socket_pair.lib Debug\end2end_fixture_chttp2_socket_pair_one_byte_at_a_time.lib Debug\end2end_fixture_chttp2_socket_pair_with_grpc_trace.lib Debug\end2end_test_bad_hostname.lib Debug\end2end_test_cancel_after_accept.lib Debug\end2end_test_cancel_after_accept_and_writes_closed.lib Debug\end2end_test_cancel_after_invoke.lib Debug\end2end_test_cancel_before_invoke.lib Debug\end2end_test_cancel_in_a_vacuum.lib Debug\end2end_test_census_simple_request.lib Debug\end2end_test_disappearing_server.lib Debug\end2end_test_early_server_shutdown_finishes_inflight_calls.lib Debug\end2end_test_early_server_shutdown_finishes_tags.lib Debug\end2end_test_empty_batch.lib Debug\end2end_test_graceful_server_shutdown.lib Debug\end2end_test_invoke_large_request.lib Debug\end2end_test_max_concurrent_streams.lib Debug\end2end_test_max_message_length.lib Debug\end2end_test_no_op.lib Debug\end2end_test_ping_pong_streaming.lib Debug\end2end_test_registered_call.lib Debug\end2end_test_request_response_with_binary_metadata_and_payload.lib Debug\end2end_test_request_response_with_metadata_and_payload.lib Debug\end2end_test_request_response_with_payload.lib Debug\end2end_test_request_response_with_payload_and_call_creds.lib Debug\end2end_test_request_response_with_trailing_metadata_and_payload.lib Debug\end2end_test_request_with_flags.lib Debug\end2end_test_request_with_large_metadata.lib Debug\end2end_test_request_with_payload.lib Debug\end2end_test_server_finishes_request.lib Debug\end2end_test_simple_delayed_request.lib Debug\end2end_test_simple_request.lib Debug\end2end_test_simple_request_with_high_initial_sequence_number.lib Debug\end2end_certs.lib Debug\bad_client_test.lib buildtests: buildtests_c buildtests_cxx -buildtests_c: alarm_heap_test.exe alarm_list_test.exe alarm_test.exe alpn_test.exe bin_encoder_test.exe chttp2_status_conversion_test.exe chttp2_stream_encoder_test.exe chttp2_stream_map_test.exe fling_client.exe fling_server.exe gpr_cancellable_test.exe gpr_cmdline_test.exe gpr_env_test.exe gpr_file_test.exe gpr_histogram_test.exe gpr_host_port_test.exe gpr_log_test.exe gpr_slice_buffer_test.exe gpr_slice_test.exe gpr_string_test.exe gpr_sync_test.exe gpr_thd_test.exe gpr_time_test.exe gpr_tls_test.exe gpr_useful_test.exe grpc_auth_context_test.exe grpc_base64_test.exe grpc_byte_buffer_reader_test.exe grpc_channel_stack_test.exe grpc_completion_queue_test.exe grpc_credentials_test.exe grpc_json_token_test.exe grpc_security_connector_test.exe grpc_stream_op_test.exe hpack_parser_test.exe hpack_table_test.exe httpcli_format_request_test.exe httpcli_parser_test.exe json_rewrite.exe json_rewrite_test.exe json_test.exe lame_client_test.exe message_compress_test.exe multi_init_test.exe murmur_hash_test.exe no_server_test.exe resolve_address_test.exe secure_endpoint_test.exe sockaddr_utils_test.exe time_averaged_stats_test.exe time_test.exe timeout_encoding_test.exe timers_test.exe transport_metadata_test.exe transport_security_test.exe chttp2_fake_security_bad_hostname_test.exe chttp2_fake_security_cancel_after_accept_test.exe chttp2_fake_security_cancel_after_accept_and_writes_closed_test.exe chttp2_fake_security_cancel_after_invoke_test.exe chttp2_fake_security_cancel_before_invoke_test.exe chttp2_fake_security_cancel_in_a_vacuum_test.exe chttp2_fake_security_census_simple_request_test.exe chttp2_fake_security_disappearing_server_test.exe chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_fake_security_early_server_shutdown_finishes_tags_test.exe chttp2_fake_security_empty_batch_test.exe chttp2_fake_security_graceful_server_shutdown_test.exe chttp2_fake_security_invoke_large_request_test.exe chttp2_fake_security_max_concurrent_streams_test.exe chttp2_fake_security_max_message_length_test.exe chttp2_fake_security_no_op_test.exe chttp2_fake_security_ping_pong_streaming_test.exe chttp2_fake_security_registered_call_test.exe chttp2_fake_security_request_response_with_binary_metadata_and_payload_test.exe chttp2_fake_security_request_response_with_metadata_and_payload_test.exe chttp2_fake_security_request_response_with_payload_test.exe chttp2_fake_security_request_response_with_payload_and_call_creds_test.exe chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test.exe chttp2_fake_security_request_with_flags_test.exe chttp2_fake_security_request_with_large_metadata_test.exe chttp2_fake_security_request_with_payload_test.exe chttp2_fake_security_server_finishes_request_test.exe chttp2_fake_security_simple_delayed_request_test.exe chttp2_fake_security_simple_request_test.exe chttp2_fake_security_simple_request_with_high_initial_sequence_number_test.exe chttp2_fullstack_bad_hostname_test.exe chttp2_fullstack_cancel_after_accept_test.exe chttp2_fullstack_cancel_after_accept_and_writes_closed_test.exe chttp2_fullstack_cancel_after_invoke_test.exe chttp2_fullstack_cancel_before_invoke_test.exe chttp2_fullstack_cancel_in_a_vacuum_test.exe chttp2_fullstack_census_simple_request_test.exe chttp2_fullstack_disappearing_server_test.exe chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_fullstack_early_server_shutdown_finishes_tags_test.exe chttp2_fullstack_empty_batch_test.exe chttp2_fullstack_graceful_server_shutdown_test.exe chttp2_fullstack_invoke_large_request_test.exe chttp2_fullstack_max_concurrent_streams_test.exe chttp2_fullstack_max_message_length_test.exe chttp2_fullstack_no_op_test.exe chttp2_fullstack_ping_pong_streaming_test.exe chttp2_fullstack_registered_call_test.exe chttp2_fullstack_request_response_with_binary_metadata_and_payload_test.exe chttp2_fullstack_request_response_with_metadata_and_payload_test.exe chttp2_fullstack_request_response_with_payload_test.exe chttp2_fullstack_request_response_with_payload_and_call_creds_test.exe chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test.exe chttp2_fullstack_request_with_flags_test.exe chttp2_fullstack_request_with_large_metadata_test.exe chttp2_fullstack_request_with_payload_test.exe chttp2_fullstack_server_finishes_request_test.exe chttp2_fullstack_simple_delayed_request_test.exe chttp2_fullstack_simple_request_test.exe chttp2_fullstack_simple_request_with_high_initial_sequence_number_test.exe chttp2_simple_ssl_fullstack_bad_hostname_test.exe chttp2_simple_ssl_fullstack_cancel_after_accept_test.exe chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test.exe chttp2_simple_ssl_fullstack_cancel_after_invoke_test.exe chttp2_simple_ssl_fullstack_cancel_before_invoke_test.exe chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test.exe chttp2_simple_ssl_fullstack_census_simple_request_test.exe chttp2_simple_ssl_fullstack_disappearing_server_test.exe chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test.exe chttp2_simple_ssl_fullstack_empty_batch_test.exe chttp2_simple_ssl_fullstack_graceful_server_shutdown_test.exe chttp2_simple_ssl_fullstack_invoke_large_request_test.exe chttp2_simple_ssl_fullstack_max_concurrent_streams_test.exe chttp2_simple_ssl_fullstack_max_message_length_test.exe chttp2_simple_ssl_fullstack_no_op_test.exe chttp2_simple_ssl_fullstack_ping_pong_streaming_test.exe chttp2_simple_ssl_fullstack_registered_call_test.exe chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test.exe chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test.exe chttp2_simple_ssl_fullstack_request_response_with_payload_test.exe chttp2_simple_ssl_fullstack_request_response_with_payload_and_call_creds_test.exe chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test.exe chttp2_simple_ssl_fullstack_request_with_flags_test.exe chttp2_simple_ssl_fullstack_request_with_large_metadata_test.exe chttp2_simple_ssl_fullstack_request_with_payload_test.exe chttp2_simple_ssl_fullstack_server_finishes_request_test.exe chttp2_simple_ssl_fullstack_simple_delayed_request_test.exe chttp2_simple_ssl_fullstack_simple_request_test.exe chttp2_simple_ssl_fullstack_simple_request_with_high_initial_sequence_number_test.exe chttp2_simple_ssl_with_oauth2_fullstack_bad_hostname_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test.exe chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test.exe chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test.exe chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test.exe chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test.exe chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test.exe chttp2_simple_ssl_with_oauth2_fullstack_max_message_length_test.exe chttp2_simple_ssl_with_oauth2_fullstack_no_op_test.exe chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test.exe chttp2_simple_ssl_with_oauth2_fullstack_registered_call_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_and_call_creds_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_with_flags_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_server_finishes_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_simple_request_with_high_initial_sequence_number_test.exe chttp2_socket_pair_bad_hostname_test.exe chttp2_socket_pair_cancel_after_accept_test.exe chttp2_socket_pair_cancel_after_accept_and_writes_closed_test.exe chttp2_socket_pair_cancel_after_invoke_test.exe chttp2_socket_pair_cancel_before_invoke_test.exe chttp2_socket_pair_cancel_in_a_vacuum_test.exe chttp2_socket_pair_census_simple_request_test.exe chttp2_socket_pair_disappearing_server_test.exe chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_socket_pair_early_server_shutdown_finishes_tags_test.exe chttp2_socket_pair_empty_batch_test.exe chttp2_socket_pair_graceful_server_shutdown_test.exe chttp2_socket_pair_invoke_large_request_test.exe chttp2_socket_pair_max_concurrent_streams_test.exe chttp2_socket_pair_max_message_length_test.exe chttp2_socket_pair_no_op_test.exe chttp2_socket_pair_ping_pong_streaming_test.exe chttp2_socket_pair_registered_call_test.exe chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test.exe chttp2_socket_pair_request_response_with_metadata_and_payload_test.exe chttp2_socket_pair_request_response_with_payload_test.exe chttp2_socket_pair_request_response_with_payload_and_call_creds_test.exe chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test.exe chttp2_socket_pair_request_with_flags_test.exe chttp2_socket_pair_request_with_large_metadata_test.exe chttp2_socket_pair_request_with_payload_test.exe chttp2_socket_pair_server_finishes_request_test.exe chttp2_socket_pair_simple_delayed_request_test.exe chttp2_socket_pair_simple_request_test.exe chttp2_socket_pair_simple_request_with_high_initial_sequence_number_test.exe chttp2_socket_pair_one_byte_at_a_time_bad_hostname_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test.exe chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test.exe chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test.exe chttp2_socket_pair_one_byte_at_a_time_empty_batch_test.exe chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test.exe chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test.exe chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test.exe chttp2_socket_pair_one_byte_at_a_time_max_message_length_test.exe chttp2_socket_pair_one_byte_at_a_time_no_op_test.exe chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test.exe chttp2_socket_pair_one_byte_at_a_time_registered_call_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_and_call_creds_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_flags_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_test.exe chttp2_socket_pair_with_grpc_trace_bad_hostname_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_test.exe chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_test.exe chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_test.exe chttp2_socket_pair_with_grpc_trace_census_simple_request_test.exe chttp2_socket_pair_with_grpc_trace_disappearing_server_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_test.exe chttp2_socket_pair_with_grpc_trace_empty_batch_test.exe chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_test.exe chttp2_socket_pair_with_grpc_trace_invoke_large_request_test.exe chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_test.exe chttp2_socket_pair_with_grpc_trace_max_message_length_test.exe chttp2_socket_pair_with_grpc_trace_no_op_test.exe chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_test.exe chttp2_socket_pair_with_grpc_trace_registered_call_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_payload_and_call_creds_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_with_flags_test.exe chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_test.exe chttp2_socket_pair_with_grpc_trace_request_with_payload_test.exe chttp2_socket_pair_with_grpc_trace_server_finishes_request_test.exe chttp2_socket_pair_with_grpc_trace_simple_delayed_request_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_test.exe chttp2_fullstack_bad_hostname_unsecure_test.exe chttp2_fullstack_cancel_after_accept_unsecure_test.exe chttp2_fullstack_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_fullstack_cancel_after_invoke_unsecure_test.exe chttp2_fullstack_cancel_before_invoke_unsecure_test.exe chttp2_fullstack_cancel_in_a_vacuum_unsecure_test.exe chttp2_fullstack_census_simple_request_unsecure_test.exe chttp2_fullstack_disappearing_server_unsecure_test.exe chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_fullstack_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_fullstack_empty_batch_unsecure_test.exe chttp2_fullstack_graceful_server_shutdown_unsecure_test.exe chttp2_fullstack_invoke_large_request_unsecure_test.exe chttp2_fullstack_max_concurrent_streams_unsecure_test.exe chttp2_fullstack_max_message_length_unsecure_test.exe chttp2_fullstack_no_op_unsecure_test.exe chttp2_fullstack_ping_pong_streaming_unsecure_test.exe chttp2_fullstack_registered_call_unsecure_test.exe chttp2_fullstack_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_fullstack_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_fullstack_request_response_with_payload_unsecure_test.exe chttp2_fullstack_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_fullstack_request_with_flags_unsecure_test.exe chttp2_fullstack_request_with_large_metadata_unsecure_test.exe chttp2_fullstack_request_with_payload_unsecure_test.exe chttp2_fullstack_server_finishes_request_unsecure_test.exe chttp2_fullstack_simple_delayed_request_unsecure_test.exe chttp2_fullstack_simple_request_unsecure_test.exe chttp2_fullstack_simple_request_with_high_initial_sequence_number_unsecure_test.exe chttp2_socket_pair_bad_hostname_unsecure_test.exe chttp2_socket_pair_cancel_after_accept_unsecure_test.exe chttp2_socket_pair_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_socket_pair_cancel_after_invoke_unsecure_test.exe chttp2_socket_pair_cancel_before_invoke_unsecure_test.exe chttp2_socket_pair_cancel_in_a_vacuum_unsecure_test.exe chttp2_socket_pair_census_simple_request_unsecure_test.exe chttp2_socket_pair_disappearing_server_unsecure_test.exe chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_socket_pair_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_socket_pair_empty_batch_unsecure_test.exe chttp2_socket_pair_graceful_server_shutdown_unsecure_test.exe chttp2_socket_pair_invoke_large_request_unsecure_test.exe chttp2_socket_pair_max_concurrent_streams_unsecure_test.exe chttp2_socket_pair_max_message_length_unsecure_test.exe chttp2_socket_pair_no_op_unsecure_test.exe chttp2_socket_pair_ping_pong_streaming_unsecure_test.exe chttp2_socket_pair_registered_call_unsecure_test.exe chttp2_socket_pair_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_request_response_with_payload_unsecure_test.exe chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_request_with_flags_unsecure_test.exe chttp2_socket_pair_request_with_large_metadata_unsecure_test.exe chttp2_socket_pair_request_with_payload_unsecure_test.exe chttp2_socket_pair_server_finishes_request_unsecure_test.exe chttp2_socket_pair_simple_delayed_request_unsecure_test.exe chttp2_socket_pair_simple_request_unsecure_test.exe chttp2_socket_pair_simple_request_with_high_initial_sequence_number_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_bad_hostname_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_census_simple_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_disappearing_server_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_empty_batch_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_max_message_length_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_no_op_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_registered_call_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_flags_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_bad_hostname_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_census_simple_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_disappearing_server_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_empty_batch_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_invoke_large_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_max_message_length_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_no_op_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_registered_call_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_with_flags_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_with_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_server_finishes_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_simple_delayed_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_unsecure_test.exe connection_prefix_bad_client_test.exe initial_settings_frame_bad_client_test.exe +buildtests_c: alarm_heap_test.exe alarm_list_test.exe alarm_test.exe alpn_test.exe bin_encoder_test.exe chttp2_status_conversion_test.exe chttp2_stream_encoder_test.exe chttp2_stream_map_test.exe fling_client.exe fling_server.exe gpr_cancellable_test.exe gpr_cmdline_test.exe gpr_env_test.exe gpr_file_test.exe gpr_histogram_test.exe gpr_host_port_test.exe gpr_log_test.exe gpr_slice_buffer_test.exe gpr_slice_test.exe gpr_string_test.exe gpr_sync_test.exe gpr_thd_test.exe gpr_time_test.exe gpr_tls_test.exe gpr_useful_test.exe grpc_auth_context_test.exe grpc_base64_test.exe grpc_byte_buffer_reader_test.exe grpc_channel_stack_test.exe grpc_completion_queue_test.exe grpc_credentials_test.exe grpc_json_token_test.exe grpc_security_connector_test.exe grpc_stream_op_test.exe hpack_parser_test.exe hpack_table_test.exe httpcli_format_request_test.exe httpcli_parser_test.exe json_rewrite.exe json_rewrite_test.exe json_test.exe lame_client_test.exe message_compress_test.exe multi_init_test.exe murmur_hash_test.exe no_server_test.exe resolve_address_test.exe secure_endpoint_test.exe sockaddr_utils_test.exe time_averaged_stats_test.exe time_test.exe timeout_encoding_test.exe timers_test.exe transport_metadata_test.exe transport_security_test.exe uri_parser_test.exe chttp2_fake_security_bad_hostname_test.exe chttp2_fake_security_cancel_after_accept_test.exe chttp2_fake_security_cancel_after_accept_and_writes_closed_test.exe chttp2_fake_security_cancel_after_invoke_test.exe chttp2_fake_security_cancel_before_invoke_test.exe chttp2_fake_security_cancel_in_a_vacuum_test.exe chttp2_fake_security_census_simple_request_test.exe chttp2_fake_security_disappearing_server_test.exe chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_fake_security_early_server_shutdown_finishes_tags_test.exe chttp2_fake_security_empty_batch_test.exe chttp2_fake_security_graceful_server_shutdown_test.exe chttp2_fake_security_invoke_large_request_test.exe chttp2_fake_security_max_concurrent_streams_test.exe chttp2_fake_security_max_message_length_test.exe chttp2_fake_security_no_op_test.exe chttp2_fake_security_ping_pong_streaming_test.exe chttp2_fake_security_registered_call_test.exe chttp2_fake_security_request_response_with_binary_metadata_and_payload_test.exe chttp2_fake_security_request_response_with_metadata_and_payload_test.exe chttp2_fake_security_request_response_with_payload_test.exe chttp2_fake_security_request_response_with_payload_and_call_creds_test.exe chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test.exe chttp2_fake_security_request_with_flags_test.exe chttp2_fake_security_request_with_large_metadata_test.exe chttp2_fake_security_request_with_payload_test.exe chttp2_fake_security_server_finishes_request_test.exe chttp2_fake_security_simple_delayed_request_test.exe chttp2_fake_security_simple_request_test.exe chttp2_fake_security_simple_request_with_high_initial_sequence_number_test.exe chttp2_fullstack_bad_hostname_test.exe chttp2_fullstack_cancel_after_accept_test.exe chttp2_fullstack_cancel_after_accept_and_writes_closed_test.exe chttp2_fullstack_cancel_after_invoke_test.exe chttp2_fullstack_cancel_before_invoke_test.exe chttp2_fullstack_cancel_in_a_vacuum_test.exe chttp2_fullstack_census_simple_request_test.exe chttp2_fullstack_disappearing_server_test.exe chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_fullstack_early_server_shutdown_finishes_tags_test.exe chttp2_fullstack_empty_batch_test.exe chttp2_fullstack_graceful_server_shutdown_test.exe chttp2_fullstack_invoke_large_request_test.exe chttp2_fullstack_max_concurrent_streams_test.exe chttp2_fullstack_max_message_length_test.exe chttp2_fullstack_no_op_test.exe chttp2_fullstack_ping_pong_streaming_test.exe chttp2_fullstack_registered_call_test.exe chttp2_fullstack_request_response_with_binary_metadata_and_payload_test.exe chttp2_fullstack_request_response_with_metadata_and_payload_test.exe chttp2_fullstack_request_response_with_payload_test.exe chttp2_fullstack_request_response_with_payload_and_call_creds_test.exe chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test.exe chttp2_fullstack_request_with_flags_test.exe chttp2_fullstack_request_with_large_metadata_test.exe chttp2_fullstack_request_with_payload_test.exe chttp2_fullstack_server_finishes_request_test.exe chttp2_fullstack_simple_delayed_request_test.exe chttp2_fullstack_simple_request_test.exe chttp2_fullstack_simple_request_with_high_initial_sequence_number_test.exe chttp2_simple_ssl_fullstack_bad_hostname_test.exe chttp2_simple_ssl_fullstack_cancel_after_accept_test.exe chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test.exe chttp2_simple_ssl_fullstack_cancel_after_invoke_test.exe chttp2_simple_ssl_fullstack_cancel_before_invoke_test.exe chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test.exe chttp2_simple_ssl_fullstack_census_simple_request_test.exe chttp2_simple_ssl_fullstack_disappearing_server_test.exe chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test.exe chttp2_simple_ssl_fullstack_empty_batch_test.exe chttp2_simple_ssl_fullstack_graceful_server_shutdown_test.exe chttp2_simple_ssl_fullstack_invoke_large_request_test.exe chttp2_simple_ssl_fullstack_max_concurrent_streams_test.exe chttp2_simple_ssl_fullstack_max_message_length_test.exe chttp2_simple_ssl_fullstack_no_op_test.exe chttp2_simple_ssl_fullstack_ping_pong_streaming_test.exe chttp2_simple_ssl_fullstack_registered_call_test.exe chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test.exe chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test.exe chttp2_simple_ssl_fullstack_request_response_with_payload_test.exe chttp2_simple_ssl_fullstack_request_response_with_payload_and_call_creds_test.exe chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test.exe chttp2_simple_ssl_fullstack_request_with_flags_test.exe chttp2_simple_ssl_fullstack_request_with_large_metadata_test.exe chttp2_simple_ssl_fullstack_request_with_payload_test.exe chttp2_simple_ssl_fullstack_server_finishes_request_test.exe chttp2_simple_ssl_fullstack_simple_delayed_request_test.exe chttp2_simple_ssl_fullstack_simple_request_test.exe chttp2_simple_ssl_fullstack_simple_request_with_high_initial_sequence_number_test.exe chttp2_simple_ssl_with_oauth2_fullstack_bad_hostname_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test.exe chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test.exe chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test.exe chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test.exe chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test.exe chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test.exe chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test.exe chttp2_simple_ssl_with_oauth2_fullstack_max_message_length_test.exe chttp2_simple_ssl_with_oauth2_fullstack_no_op_test.exe chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test.exe chttp2_simple_ssl_with_oauth2_fullstack_registered_call_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_and_call_creds_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_with_flags_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test.exe chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test.exe chttp2_simple_ssl_with_oauth2_fullstack_server_finishes_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test.exe chttp2_simple_ssl_with_oauth2_fullstack_simple_request_with_high_initial_sequence_number_test.exe chttp2_socket_pair_bad_hostname_test.exe chttp2_socket_pair_cancel_after_accept_test.exe chttp2_socket_pair_cancel_after_accept_and_writes_closed_test.exe chttp2_socket_pair_cancel_after_invoke_test.exe chttp2_socket_pair_cancel_before_invoke_test.exe chttp2_socket_pair_cancel_in_a_vacuum_test.exe chttp2_socket_pair_census_simple_request_test.exe chttp2_socket_pair_disappearing_server_test.exe chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_socket_pair_early_server_shutdown_finishes_tags_test.exe chttp2_socket_pair_empty_batch_test.exe chttp2_socket_pair_graceful_server_shutdown_test.exe chttp2_socket_pair_invoke_large_request_test.exe chttp2_socket_pair_max_concurrent_streams_test.exe chttp2_socket_pair_max_message_length_test.exe chttp2_socket_pair_no_op_test.exe chttp2_socket_pair_ping_pong_streaming_test.exe chttp2_socket_pair_registered_call_test.exe chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test.exe chttp2_socket_pair_request_response_with_metadata_and_payload_test.exe chttp2_socket_pair_request_response_with_payload_test.exe chttp2_socket_pair_request_response_with_payload_and_call_creds_test.exe chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test.exe chttp2_socket_pair_request_with_flags_test.exe chttp2_socket_pair_request_with_large_metadata_test.exe chttp2_socket_pair_request_with_payload_test.exe chttp2_socket_pair_server_finishes_request_test.exe chttp2_socket_pair_simple_delayed_request_test.exe chttp2_socket_pair_simple_request_test.exe chttp2_socket_pair_simple_request_with_high_initial_sequence_number_test.exe chttp2_socket_pair_one_byte_at_a_time_bad_hostname_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test.exe chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test.exe chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test.exe chttp2_socket_pair_one_byte_at_a_time_empty_batch_test.exe chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test.exe chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test.exe chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test.exe chttp2_socket_pair_one_byte_at_a_time_max_message_length_test.exe chttp2_socket_pair_one_byte_at_a_time_no_op_test.exe chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test.exe chttp2_socket_pair_one_byte_at_a_time_registered_call_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_and_call_creds_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_flags_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test.exe chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_test.exe chttp2_socket_pair_with_grpc_trace_bad_hostname_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_test.exe chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_test.exe chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_test.exe chttp2_socket_pair_with_grpc_trace_census_simple_request_test.exe chttp2_socket_pair_with_grpc_trace_disappearing_server_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_test.exe chttp2_socket_pair_with_grpc_trace_empty_batch_test.exe chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_test.exe chttp2_socket_pair_with_grpc_trace_invoke_large_request_test.exe chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_test.exe chttp2_socket_pair_with_grpc_trace_max_message_length_test.exe chttp2_socket_pair_with_grpc_trace_no_op_test.exe chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_test.exe chttp2_socket_pair_with_grpc_trace_registered_call_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_payload_and_call_creds_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_test.exe chttp2_socket_pair_with_grpc_trace_request_with_flags_test.exe chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_test.exe chttp2_socket_pair_with_grpc_trace_request_with_payload_test.exe chttp2_socket_pair_with_grpc_trace_server_finishes_request_test.exe chttp2_socket_pair_with_grpc_trace_simple_delayed_request_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_test.exe chttp2_fullstack_bad_hostname_unsecure_test.exe chttp2_fullstack_cancel_after_accept_unsecure_test.exe chttp2_fullstack_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_fullstack_cancel_after_invoke_unsecure_test.exe chttp2_fullstack_cancel_before_invoke_unsecure_test.exe chttp2_fullstack_cancel_in_a_vacuum_unsecure_test.exe chttp2_fullstack_census_simple_request_unsecure_test.exe chttp2_fullstack_disappearing_server_unsecure_test.exe chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_fullstack_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_fullstack_empty_batch_unsecure_test.exe chttp2_fullstack_graceful_server_shutdown_unsecure_test.exe chttp2_fullstack_invoke_large_request_unsecure_test.exe chttp2_fullstack_max_concurrent_streams_unsecure_test.exe chttp2_fullstack_max_message_length_unsecure_test.exe chttp2_fullstack_no_op_unsecure_test.exe chttp2_fullstack_ping_pong_streaming_unsecure_test.exe chttp2_fullstack_registered_call_unsecure_test.exe chttp2_fullstack_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_fullstack_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_fullstack_request_response_with_payload_unsecure_test.exe chttp2_fullstack_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_fullstack_request_with_flags_unsecure_test.exe chttp2_fullstack_request_with_large_metadata_unsecure_test.exe chttp2_fullstack_request_with_payload_unsecure_test.exe chttp2_fullstack_server_finishes_request_unsecure_test.exe chttp2_fullstack_simple_delayed_request_unsecure_test.exe chttp2_fullstack_simple_request_unsecure_test.exe chttp2_fullstack_simple_request_with_high_initial_sequence_number_unsecure_test.exe chttp2_socket_pair_bad_hostname_unsecure_test.exe chttp2_socket_pair_cancel_after_accept_unsecure_test.exe chttp2_socket_pair_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_socket_pair_cancel_after_invoke_unsecure_test.exe chttp2_socket_pair_cancel_before_invoke_unsecure_test.exe chttp2_socket_pair_cancel_in_a_vacuum_unsecure_test.exe chttp2_socket_pair_census_simple_request_unsecure_test.exe chttp2_socket_pair_disappearing_server_unsecure_test.exe chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_socket_pair_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_socket_pair_empty_batch_unsecure_test.exe chttp2_socket_pair_graceful_server_shutdown_unsecure_test.exe chttp2_socket_pair_invoke_large_request_unsecure_test.exe chttp2_socket_pair_max_concurrent_streams_unsecure_test.exe chttp2_socket_pair_max_message_length_unsecure_test.exe chttp2_socket_pair_no_op_unsecure_test.exe chttp2_socket_pair_ping_pong_streaming_unsecure_test.exe chttp2_socket_pair_registered_call_unsecure_test.exe chttp2_socket_pair_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_request_response_with_payload_unsecure_test.exe chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_request_with_flags_unsecure_test.exe chttp2_socket_pair_request_with_large_metadata_unsecure_test.exe chttp2_socket_pair_request_with_payload_unsecure_test.exe chttp2_socket_pair_server_finishes_request_unsecure_test.exe chttp2_socket_pair_simple_delayed_request_unsecure_test.exe chttp2_socket_pair_simple_request_unsecure_test.exe chttp2_socket_pair_simple_request_with_high_initial_sequence_number_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_bad_hostname_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_census_simple_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_disappearing_server_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_empty_batch_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_max_message_length_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_no_op_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_registered_call_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_flags_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_request_with_payload_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_server_finishes_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_unsecure_test.exe chttp2_socket_pair_one_byte_at_a_time_simple_request_with_high_initial_sequence_number_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_bad_hostname_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_accept_and_writes_closed_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_after_invoke_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_before_invoke_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_cancel_in_a_vacuum_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_census_simple_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_disappearing_server_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_inflight_calls_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_early_server_shutdown_finishes_tags_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_empty_batch_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_graceful_server_shutdown_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_invoke_large_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_max_concurrent_streams_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_max_message_length_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_no_op_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_ping_pong_streaming_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_registered_call_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_binary_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_response_with_trailing_metadata_and_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_with_flags_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_with_large_metadata_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_request_with_payload_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_server_finishes_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_simple_delayed_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_unsecure_test.exe chttp2_socket_pair_with_grpc_trace_simple_request_with_high_initial_sequence_number_unsecure_test.exe connection_prefix_bad_client_test.exe initial_settings_frame_bad_client_test.exe echo All tests built. buildtests_cxx: interop_client.exe interop_server.exe @@ -483,6 +483,13 @@ transport_security_test.exe: build_libs $(OUT_DIR) transport_security_test: transport_security_test.exe echo Running transport_security_test $(OUT_DIR)\transport_security_test.exe +uri_parser_test.exe: build_libs $(OUT_DIR) + echo Building uri_parser_test + $(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\test\core\client_config\uri_parser_test.c + $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\uri_parser_test.exe" Debug\grpc_test_util.lib Debug\grpc.lib Debug\gpr_test_util.lib Debug\gpr.lib $(LIBS) $(OUT_DIR)\uri_parser_test.obj +uri_parser_test: uri_parser_test.exe + echo Running uri_parser_test + $(OUT_DIR)\uri_parser_test.exe interop_client.exe: build_libs $(OUT_DIR) echo Building interop_client $(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\vsprojects\dummy.c diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 728174258e2..51529068cc5 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -185,11 +185,15 @@ + + + + @@ -332,16 +336,24 @@ + + + + + + + + diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index 2220d06558c..c7281c68c70 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -103,6 +103,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config @@ -112,12 +115,21 @@ src\core\client_config + + src\core\client_config + + + src\core\client_config\resolvers + src\core\client_config src\core\client_config + + src\core\client_config + src\core\compression @@ -485,6 +497,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config @@ -494,12 +509,21 @@ src\core\client_config + + src\core\client_config + + + src\core\client_config\resolvers + src\core\client_config src\core\client_config + + src\core\client_config + src\core\compression @@ -740,6 +764,12 @@ {e71e6928-b1e3-0616-0961-1505370458ab} + + {a3eca4d5-f760-61a6-7251-556b828c8b44} + + + {6d97b8d9-2c15-927a-892a-709d073c02ab} + {263cb913-dfe6-42a4-096b-cac231f76305} diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index a0b1d9f2e55..597dd2dc70b 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -167,11 +167,15 @@ + + + + @@ -270,16 +274,24 @@ + + + + + + + + diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index 8b170bf3f65..55f86a6a65f 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -37,6 +37,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config @@ -46,12 +49,21 @@ src\core\client_config + + src\core\client_config + + + src\core\client_config\resolvers + src\core\client_config src\core\client_config + + src\core\client_config + src\core\compression @@ -368,6 +380,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config @@ -377,12 +392,21 @@ src\core\client_config + + src\core\client_config + + + src\core\client_config\resolvers + src\core\client_config src\core\client_config + + src\core\client_config + src\core\compression @@ -623,6 +647,12 @@ {02bd7340-02ee-4337-ffa5-0b6ecc7cf60c} + + {308af086-46c7-fa66-9021-19b1c3d4a6bd} + + + {dd617c24-6f07-fdff-80d5-c8610d6f815e} + {2e3aca1d-223d-10a1-b282-7f9fc68ee6f5} From f5f1712e1fcca1beb555ca9ea783a9c98b9b1a64 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 08:47:26 -0700 Subject: [PATCH 032/124] Refactoring progress towards integrating client configs --- BUILD | 8 - Makefile | 4 - build.json | 4 - gRPC.podspec | 4 +- src/core/channel/child_channel.c | 308 ------------------ src/core/channel/child_channel.h | 65 ---- src/core/channel/client_channel.c | 134 ++++++-- src/core/channel/client_channel.h | 5 +- src/core/channel/client_setup.c | 302 ----------------- src/core/channel/client_setup.h | 77 ----- src/core/client_config/lb_policy.h | 3 + src/core/client_config/subchannel.h | 13 +- src/core/surface/channel.h | 5 - src/core/surface/channel_create.c | 163 +-------- tools/doxygen/Doxyfile.core.internal | 2 +- vsprojects/grpc/grpc.vcxproj | 6 - vsprojects/grpc/grpc.vcxproj.filters | 12 - .../grpc_unsecure/grpc_unsecure.vcxproj | 6 - .../grpc_unsecure.vcxproj.filters | 12 - 19 files changed, 139 insertions(+), 994 deletions(-) delete mode 100644 src/core/channel/child_channel.c delete mode 100644 src/core/channel/child_channel.h delete mode 100644 src/core/channel/client_setup.c delete mode 100644 src/core/channel/client_setup.h diff --git a/BUILD b/BUILD index 6e1bec95f5b..dcd2c7347cb 100644 --- a/BUILD +++ b/BUILD @@ -150,9 +150,7 @@ cc_library( "src/core/channel/census_filter.h", "src/core/channel/channel_args.h", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", @@ -266,9 +264,7 @@ cc_library( "src/core/census/grpc_context.c", "src/core/channel/channel_args.c", "src/core/channel/channel_stack.c", - "src/core/channel/child_channel.c", "src/core/channel/client_channel.c", - "src/core/channel/client_setup.c", "src/core/channel/connected_channel.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", @@ -396,9 +392,7 @@ cc_library( "src/core/channel/census_filter.h", "src/core/channel/channel_args.h", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", @@ -490,9 +484,7 @@ cc_library( "src/core/census/grpc_context.c", "src/core/channel/channel_args.c", "src/core/channel/channel_stack.c", - "src/core/channel/child_channel.c", "src/core/channel/client_channel.c", - "src/core/channel/client_setup.c", "src/core/channel/connected_channel.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", diff --git a/Makefile b/Makefile index 6b70396f2bc..c5ead9a7b40 100644 --- a/Makefile +++ b/Makefile @@ -3016,9 +3016,7 @@ LIBGRPC_SRC = \ src/core/census/grpc_context.c \ src/core/channel/channel_args.c \ src/core/channel/channel_stack.c \ - src/core/channel/child_channel.c \ src/core/channel/client_channel.c \ - src/core/channel/client_setup.c \ src/core/channel/connected_channel.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ @@ -3272,9 +3270,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/census/grpc_context.c \ src/core/channel/channel_args.c \ src/core/channel/channel_stack.c \ - src/core/channel/child_channel.c \ src/core/channel/client_channel.c \ - src/core/channel/client_setup.c \ src/core/channel/connected_channel.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ diff --git a/build.json b/build.json index 71f4fd8e0b0..b9fe01134af 100644 --- a/build.json +++ b/build.json @@ -111,9 +111,7 @@ "src/core/channel/census_filter.h", "src/core/channel/channel_args.h", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", @@ -205,9 +203,7 @@ "src/core/census/grpc_context.c", "src/core/channel/channel_args.c", "src/core/channel/channel_stack.c", - "src/core/channel/child_channel.c", "src/core/channel/client_channel.c", - "src/core/channel/client_setup.c", "src/core/channel/connected_channel.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", diff --git a/gRPC.podspec b/gRPC.podspec index 8564d3aa377..8532881e334 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -61,8 +61,8 @@ Pod::Spec.new do |s| # Core cross-platform gRPC library, written in C. s.subspec 'C-Core' do |ss| - ss.source_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/grpc_string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'grpc/support/alloc.h', 'grpc/support/atm.h', 'grpc/support/atm_gcc_atomic.h', 'grpc/support/atm_gcc_sync.h', 'grpc/support/atm_win32.h', 'grpc/support/cancellable_platform.h', 'grpc/support/cmdline.h', 'grpc/support/cpu.h', 'grpc/support/histogram.h', 'grpc/support/host_port.h', 'grpc/support/log.h', 'grpc/support/log_win32.h', 'grpc/support/port_platform.h', 'grpc/support/slice.h', 'grpc/support/slice_buffer.h', 'grpc/support/string_util.h', 'grpc/support/subprocess.h', 'grpc/support/sync.h', 'grpc/support/sync_generic.h', 'grpc/support/sync_posix.h', 'grpc/support/sync_win32.h', 'grpc/support/thd.h', 'grpc/support/grpc_time.h', 'grpc/support/tls.h', 'grpc/support/tls_gcc.h', 'grpc/support/tls_msvc.h', 'grpc/support/tls_pthread.h', 'grpc/support/useful.h', 'src/core/support/alloc.c', 'src/core/support/cancellable.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', 'src/core/support/cpu_linux.c', 'src/core/support/cpu_posix.c', 'src/core/support/cpu_windows.c', 'src/core/support/env_linux.c', 'src/core/support/env_posix.c', 'src/core/support/env_win32.c', 'src/core/support/file.c', 'src/core/support/file_posix.c', 'src/core/support/file_win32.c', 'src/core/support/histogram.c', 'src/core/support/host_port.c', 'src/core/support/log.c', 'src/core/support/log_android.c', 'src/core/support/log_linux.c', 'src/core/support/log_posix.c', 'src/core/support/log_win32.c', 'src/core/support/murmur_hash.c', 'src/core/support/slice.c', 'src/core/support/slice_buffer.c', 'src/core/support/string.c', 'src/core/support/string_posix.c', 'src/core/support/string_win32.c', 'src/core/support/subprocess_posix.c', 'src/core/support/sync.c', 'src/core/support/sync_posix.c', 'src/core/support/sync_win32.c', 'src/core/support/thd.c', 'src/core/support/thd_posix.c', 'src/core/support/thd_win32.c', 'src/core/support/time.c', 'src/core/support/time_posix.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', 'grpc/grpc_security.h', 'grpc/byte_buffer.h', 'grpc/byte_buffer_reader.h', 'grpc/compression.h', 'grpc/grpc.h', 'grpc/status.h', 'grpc/census.h', 'src/core/httpcli/format_request.c', 'src/core/httpcli/httpcli.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/httpcli/parser.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', 'src/core/security/credentials.c', 'src/core/security/credentials_metadata.c', 'src/core/security/credentials_posix.c', 'src/core/security/credentials_win32.c', 'src/core/security/google_default_credentials.c', 'src/core/security/json_token.c', 'src/core/security/secure_endpoint.c', 'src/core/security/secure_transport_setup.c', 'src/core/security/security_connector.c', 'src/core/security/security_context.c', 'src/core/security/server_auth_filter.c', 'src/core/security/server_secure_chttp2.c', 'src/core/surface/init_secure.c', 'src/core/surface/secure_channel_create.c', 'src/core/tsi/fake_transport_security.c', 'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/transport_security.c', 'src/core/census/grpc_context.c', 'src/core/channel/channel_args.c', 'src/core/channel/channel_stack.c', 'src/core/channel/child_channel.c', 'src/core/channel/client_channel.c', 'src/core/channel/client_setup.c', 'src/core/channel/connected_channel.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', 'src/core/client_config/client_config.c', 'src/core/client_config/lb_policies/pick_first.c', 'src/core/client_config/lb_policy.c', 'src/core/client_config/resolver.c', 'src/core/client_config/resolver_factory.c', 'src/core/client_config/resolver_registry.c', 'src/core/client_config/resolvers/dns_resolver.c', 'src/core/client_config/subchannel.c', 'src/core/client_config/subchannel_factory.c', 'src/core/client_config/uri_parser.c', 'src/core/compression/algorithm.c', 'src/core/compression/message_compress.c', 'src/core/debug/trace.c', 'src/core/iomgr/alarm.c', 'src/core/iomgr/alarm_heap.c', 'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_windows.c', 'src/core/iomgr/fd_posix.c', 'src/core/iomgr/iocp_windows.c', 'src/core/iomgr/iomgr.c', 'src/core/iomgr/iomgr_posix.c', 'src/core/iomgr/iomgr_windows.c', 'src/core/iomgr/pollset_kick_posix.c', 'src/core/iomgr/pollset_multipoller_with_epoll.c', 'src/core/iomgr/pollset_multipoller_with_poll_posix.c', 'src/core/iomgr/pollset_posix.c', 'src/core/iomgr/pollset_set_posix.c', 'src/core/iomgr/pollset_set_windows.c', 'src/core/iomgr/pollset_windows.c', 'src/core/iomgr/resolve_address_posix.c', 'src/core/iomgr/resolve_address_windows.c', 'src/core/iomgr/sockaddr_utils.c', 'src/core/iomgr/socket_utils_common_posix.c', 'src/core/iomgr/socket_utils_linux.c', 'src/core/iomgr/socket_utils_posix.c', 'src/core/iomgr/socket_windows.c', 'src/core/iomgr/tcp_client_posix.c', 'src/core/iomgr/tcp_client_windows.c', 'src/core/iomgr/tcp_posix.c', 'src/core/iomgr/tcp_server_posix.c', 'src/core/iomgr/tcp_server_windows.c', 'src/core/iomgr/tcp_windows.c', 'src/core/iomgr/time_averaged_stats.c', 'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_posix.c', 'src/core/json/json.c', 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', 'src/core/profiling/basic_timers.c', 'src/core/profiling/stap_timers.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', 'src/core/surface/byte_buffer_reader.c', 'src/core/surface/call.c', 'src/core/surface/call_details.c', 'src/core/surface/call_log_batch.c', 'src/core/surface/channel.c', 'src/core/surface/channel_create.c', 'src/core/surface/client.c', 'src/core/surface/completion_queue.c', 'src/core/surface/event_string.c', 'src/core/surface/init.c', 'src/core/surface/lame_client.c', 'src/core/surface/metadata_array.c', 'src/core/surface/server.c', 'src/core/surface/server_chttp2.c', 'src/core/surface/server_create.c', 'src/core/surface/surface_trace.c', 'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/bin_encoder.c', 'src/core/transport/chttp2/frame_data.c', 'src/core/transport/chttp2/frame_goaway.c', 'src/core/transport/chttp2/frame_ping.c', 'src/core/transport/chttp2/frame_rst_stream.c', 'src/core/transport/chttp2/frame_settings.c', 'src/core/transport/chttp2/frame_window_update.c', 'src/core/transport/chttp2/hpack_parser.c', 'src/core/transport/chttp2/hpack_table.c', 'src/core/transport/chttp2/huffsyms.c', 'src/core/transport/chttp2/status_conversion.c', 'src/core/transport/chttp2/stream_encoder.c', 'src/core/transport/chttp2/stream_map.c', 'src/core/transport/chttp2/timeout_encoding.c', 'src/core/transport/chttp2/varint.c', 'src/core/transport/chttp2_transport.c', 'src/core/transport/metadata.c', 'src/core/transport/stream_op.c', 'src/core/transport/transport.c', 'src/core/transport/transport_op_string.c', 'src/core/census/context.c', 'src/core/census/initialize.c', - ss.private_header_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/child_channel.h', 'src/core/channel/client_channel.h', 'src/core/channel/client_setup.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', + ss.source_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/grpc_string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'grpc/support/alloc.h', 'grpc/support/atm.h', 'grpc/support/atm_gcc_atomic.h', 'grpc/support/atm_gcc_sync.h', 'grpc/support/atm_win32.h', 'grpc/support/cancellable_platform.h', 'grpc/support/cmdline.h', 'grpc/support/cpu.h', 'grpc/support/histogram.h', 'grpc/support/host_port.h', 'grpc/support/log.h', 'grpc/support/log_win32.h', 'grpc/support/port_platform.h', 'grpc/support/slice.h', 'grpc/support/slice_buffer.h', 'grpc/support/string_util.h', 'grpc/support/subprocess.h', 'grpc/support/sync.h', 'grpc/support/sync_generic.h', 'grpc/support/sync_posix.h', 'grpc/support/sync_win32.h', 'grpc/support/thd.h', 'grpc/support/grpc_time.h', 'grpc/support/tls.h', 'grpc/support/tls_gcc.h', 'grpc/support/tls_msvc.h', 'grpc/support/tls_pthread.h', 'grpc/support/useful.h', 'src/core/support/alloc.c', 'src/core/support/cancellable.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', 'src/core/support/cpu_linux.c', 'src/core/support/cpu_posix.c', 'src/core/support/cpu_windows.c', 'src/core/support/env_linux.c', 'src/core/support/env_posix.c', 'src/core/support/env_win32.c', 'src/core/support/file.c', 'src/core/support/file_posix.c', 'src/core/support/file_win32.c', 'src/core/support/histogram.c', 'src/core/support/host_port.c', 'src/core/support/log.c', 'src/core/support/log_android.c', 'src/core/support/log_linux.c', 'src/core/support/log_posix.c', 'src/core/support/log_win32.c', 'src/core/support/murmur_hash.c', 'src/core/support/slice.c', 'src/core/support/slice_buffer.c', 'src/core/support/string.c', 'src/core/support/string_posix.c', 'src/core/support/string_win32.c', 'src/core/support/subprocess_posix.c', 'src/core/support/sync.c', 'src/core/support/sync_posix.c', 'src/core/support/sync_win32.c', 'src/core/support/thd.c', 'src/core/support/thd_posix.c', 'src/core/support/thd_win32.c', 'src/core/support/time.c', 'src/core/support/time_posix.c', 'src/core/support/time_win32.c', 'src/core/support/tls_pthread.c', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/client_channel.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', 'grpc/grpc_security.h', 'grpc/byte_buffer.h', 'grpc/byte_buffer_reader.h', 'grpc/compression.h', 'grpc/grpc.h', 'grpc/status.h', 'grpc/census.h', 'src/core/httpcli/format_request.c', 'src/core/httpcli/httpcli.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/httpcli/parser.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', 'src/core/security/credentials.c', 'src/core/security/credentials_metadata.c', 'src/core/security/credentials_posix.c', 'src/core/security/credentials_win32.c', 'src/core/security/google_default_credentials.c', 'src/core/security/json_token.c', 'src/core/security/secure_endpoint.c', 'src/core/security/secure_transport_setup.c', 'src/core/security/security_connector.c', 'src/core/security/security_context.c', 'src/core/security/server_auth_filter.c', 'src/core/security/server_secure_chttp2.c', 'src/core/surface/init_secure.c', 'src/core/surface/secure_channel_create.c', 'src/core/tsi/fake_transport_security.c', 'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/transport_security.c', 'src/core/census/grpc_context.c', 'src/core/channel/channel_args.c', 'src/core/channel/channel_stack.c', 'src/core/channel/client_channel.c', 'src/core/channel/connected_channel.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', 'src/core/client_config/client_config.c', 'src/core/client_config/lb_policies/pick_first.c', 'src/core/client_config/lb_policy.c', 'src/core/client_config/resolver.c', 'src/core/client_config/resolver_factory.c', 'src/core/client_config/resolver_registry.c', 'src/core/client_config/resolvers/dns_resolver.c', 'src/core/client_config/subchannel.c', 'src/core/client_config/subchannel_factory.c', 'src/core/client_config/uri_parser.c', 'src/core/compression/algorithm.c', 'src/core/compression/message_compress.c', 'src/core/debug/trace.c', 'src/core/iomgr/alarm.c', 'src/core/iomgr/alarm_heap.c', 'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_windows.c', 'src/core/iomgr/fd_posix.c', 'src/core/iomgr/iocp_windows.c', 'src/core/iomgr/iomgr.c', 'src/core/iomgr/iomgr_posix.c', 'src/core/iomgr/iomgr_windows.c', 'src/core/iomgr/pollset_kick_posix.c', 'src/core/iomgr/pollset_multipoller_with_epoll.c', 'src/core/iomgr/pollset_multipoller_with_poll_posix.c', 'src/core/iomgr/pollset_posix.c', 'src/core/iomgr/pollset_set_posix.c', 'src/core/iomgr/pollset_set_windows.c', 'src/core/iomgr/pollset_windows.c', 'src/core/iomgr/resolve_address_posix.c', 'src/core/iomgr/resolve_address_windows.c', 'src/core/iomgr/sockaddr_utils.c', 'src/core/iomgr/socket_utils_common_posix.c', 'src/core/iomgr/socket_utils_linux.c', 'src/core/iomgr/socket_utils_posix.c', 'src/core/iomgr/socket_windows.c', 'src/core/iomgr/tcp_client_posix.c', 'src/core/iomgr/tcp_client_windows.c', 'src/core/iomgr/tcp_posix.c', 'src/core/iomgr/tcp_server_posix.c', 'src/core/iomgr/tcp_server_windows.c', 'src/core/iomgr/tcp_windows.c', 'src/core/iomgr/time_averaged_stats.c', 'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_posix.c', 'src/core/json/json.c', 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', 'src/core/profiling/basic_timers.c', 'src/core/profiling/stap_timers.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', 'src/core/surface/byte_buffer_reader.c', 'src/core/surface/call.c', 'src/core/surface/call_details.c', 'src/core/surface/call_log_batch.c', 'src/core/surface/channel.c', 'src/core/surface/channel_create.c', 'src/core/surface/client.c', 'src/core/surface/completion_queue.c', 'src/core/surface/event_string.c', 'src/core/surface/init.c', 'src/core/surface/lame_client.c', 'src/core/surface/metadata_array.c', 'src/core/surface/server.c', 'src/core/surface/server_chttp2.c', 'src/core/surface/server_create.c', 'src/core/surface/surface_trace.c', 'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/bin_encoder.c', 'src/core/transport/chttp2/frame_data.c', 'src/core/transport/chttp2/frame_goaway.c', 'src/core/transport/chttp2/frame_ping.c', 'src/core/transport/chttp2/frame_rst_stream.c', 'src/core/transport/chttp2/frame_settings.c', 'src/core/transport/chttp2/frame_window_update.c', 'src/core/transport/chttp2/hpack_parser.c', 'src/core/transport/chttp2/hpack_table.c', 'src/core/transport/chttp2/huffsyms.c', 'src/core/transport/chttp2/status_conversion.c', 'src/core/transport/chttp2/stream_encoder.c', 'src/core/transport/chttp2/stream_map.c', 'src/core/transport/chttp2/timeout_encoding.c', 'src/core/transport/chttp2/varint.c', 'src/core/transport/chttp2_transport.c', 'src/core/transport/metadata.c', 'src/core/transport/stream_op.c', 'src/core/transport/transport.c', 'src/core/transport/transport_op_string.c', 'src/core/census/context.c', 'src/core/census/initialize.c', + ss.private_header_files = 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/httpcli/format_request.h', 'src/core/httpcli/httpcli.h', 'src/core/httpcli/httpcli_security_connector.h', 'src/core/httpcli/parser.h', 'src/core/security/auth_filters.h', 'src/core/security/base64.h', 'src/core/security/credentials.h', 'src/core/security/json_token.h', 'src/core/security/secure_endpoint.h', 'src/core/security/secure_transport_setup.h', 'src/core/security/security_connector.h', 'src/core/security/security_context.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security_interface.h', 'src/core/census/grpc_context.h', 'src/core/channel/census_filter.h', 'src/core/channel/channel_args.h', 'src/core/channel/channel_stack.h', 'src/core/channel/client_channel.h', 'src/core/channel/connected_channel.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', 'src/core/compression/message_compress.h', 'src/core/debug/trace.h', 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', 'src/core/iomgr/iocp_windows.h', 'src/core/iomgr/iomgr.h', 'src/core/iomgr/iomgr_internal.h', 'src/core/iomgr/iomgr_posix.h', 'src/core/iomgr/pollset.h', 'src/core/iomgr/pollset_kick_posix.h', 'src/core/iomgr/pollset_posix.h', 'src/core/iomgr/pollset_set.h', 'src/core/iomgr/pollset_set_posix.h', 'src/core/iomgr/pollset_set_windows.h', 'src/core/iomgr/pollset_windows.h', 'src/core/iomgr/resolve_address.h', 'src/core/iomgr/sockaddr.h', 'src/core/iomgr/sockaddr_posix.h', 'src/core/iomgr/sockaddr_utils.h', 'src/core/iomgr/sockaddr_win32.h', 'src/core/iomgr/socket_utils_posix.h', 'src/core/iomgr/socket_windows.h', 'src/core/iomgr/tcp_client.h', 'src/core/iomgr/tcp_posix.h', 'src/core/iomgr/tcp_server.h', 'src/core/iomgr/tcp_windows.h', 'src/core/iomgr/time_averaged_stats.h', 'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_posix.h', 'src/core/json/json.h', 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', 'src/core/profiling/timers.h', 'src/core/profiling/timers_preciseclock.h', 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', 'src/core/surface/server.h', 'src/core/surface/surface_trace.h', 'src/core/transport/chttp2/alpn.h', 'src/core/transport/chttp2/bin_encoder.h', 'src/core/transport/chttp2/frame.h', 'src/core/transport/chttp2/frame_data.h', 'src/core/transport/chttp2/frame_goaway.h', 'src/core/transport/chttp2/frame_ping.h', 'src/core/transport/chttp2/frame_rst_stream.h', 'src/core/transport/chttp2/frame_settings.h', 'src/core/transport/chttp2/frame_window_update.h', 'src/core/transport/chttp2/hpack_parser.h', 'src/core/transport/chttp2/hpack_table.h', 'src/core/transport/chttp2/http2_errors.h', 'src/core/transport/chttp2/huffsyms.h', 'src/core/transport/chttp2/status_conversion.h', 'src/core/transport/chttp2/stream_encoder.h', 'src/core/transport/chttp2/stream_map.h', 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/context.h', ss.header_mappings_dir = '.' ss.requires_arc = false diff --git a/src/core/channel/child_channel.c b/src/core/channel/child_channel.c deleted file mode 100644 index 6690265d750..00000000000 --- a/src/core/channel/child_channel.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/channel/child_channel.h" -#include "src/core/iomgr/iomgr.h" -#include - -/* Link back filter: passes up calls to the client channel, pushes down calls - down */ - -static void maybe_destroy_channel(grpc_child_channel *channel); - -typedef struct { - gpr_mu mu; - gpr_cv cv; - grpc_channel_element *back; - /* # of active calls on the channel */ - gpr_uint32 active_calls; - /* has grpc_child_channel_destroy been called? */ - gpr_uint8 destroyed; - /* has the transport reported itself disconnected? */ - gpr_uint8 disconnected; - /* are we calling 'back' - our parent channel */ - gpr_uint8 calling_back; - /* have we or our parent sent goaway yet? - dup suppression */ - gpr_uint8 sent_goaway; - /* are we currently sending farewell (in this file: goaway + disconnect) */ - gpr_uint8 sending_farewell; - /* have we sent farewell (goaway + disconnect) */ - gpr_uint8 sent_farewell; - - grpc_iomgr_closure finally_destroy_channel_closure; - grpc_iomgr_closure send_farewells_closure; -} lb_channel_data; - -typedef struct { grpc_child_channel *channel; } lb_call_data; - -static void lb_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { - grpc_call_next_op(elem, op); -} - -/* Currently we assume all channel operations should just be pushed up. */ -static void lb_channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, - grpc_channel_op *op) { - lb_channel_data *chand = elem->channel_data; - grpc_channel_element *back; - int calling_back = 0; - - switch (op->dir) { - case GRPC_CALL_UP: - gpr_mu_lock(&chand->mu); - back = chand->back; - if (back) { - chand->calling_back++; - calling_back = 1; - } - gpr_mu_unlock(&chand->mu); - if (back) { - back->filter->channel_op(chand->back, elem, op); - } else if (op->type == GRPC_TRANSPORT_GOAWAY) { - gpr_slice_unref(op->data.goaway.message); - } - break; - case GRPC_CALL_DOWN: - grpc_channel_next_op(elem, op); - break; - } - - gpr_mu_lock(&chand->mu); - switch (op->type) { - case GRPC_TRANSPORT_CLOSED: - chand->disconnected = 1; - maybe_destroy_channel(grpc_channel_stack_from_top_element(elem)); - break; - case GRPC_CHANNEL_GOAWAY: - chand->sent_goaway = 1; - break; - case GRPC_CHANNEL_DISCONNECT: - case GRPC_TRANSPORT_GOAWAY: - case GRPC_ACCEPT_CALL: - break; - } - - if (calling_back) { - chand->calling_back--; - gpr_cv_signal(&chand->cv); - maybe_destroy_channel(grpc_channel_stack_from_top_element(elem)); - } - gpr_mu_unlock(&chand->mu); -} - -/* Constructor for call_data */ -static void lb_init_call_elem(grpc_call_element *elem, - const void *server_transport_data, - grpc_transport_op *initial_op) {} - -/* Destructor for call_data */ -static void lb_destroy_call_elem(grpc_call_element *elem) {} - -/* Constructor for channel_data */ -static void lb_init_channel_elem(grpc_channel_element *elem, - const grpc_channel_args *args, - grpc_mdctx *metadata_context, int is_first, - int is_last) { - lb_channel_data *chand = elem->channel_data; - GPR_ASSERT(is_first); - GPR_ASSERT(!is_last); - gpr_mu_init(&chand->mu); - gpr_cv_init(&chand->cv); - chand->back = NULL; - chand->destroyed = 0; - chand->disconnected = 0; - chand->active_calls = 0; - chand->sent_goaway = 0; - chand->calling_back = 0; - chand->sending_farewell = 0; - chand->sent_farewell = 0; -} - -/* Destructor for channel_data */ -static void lb_destroy_channel_elem(grpc_channel_element *elem) { - lb_channel_data *chand = elem->channel_data; - gpr_mu_destroy(&chand->mu); - gpr_cv_destroy(&chand->cv); -} - -const grpc_channel_filter grpc_child_channel_top_filter = { - lb_start_transport_op, lb_channel_op, - sizeof(lb_call_data), lb_init_call_elem, lb_destroy_call_elem, - sizeof(lb_channel_data), lb_init_channel_elem, lb_destroy_channel_elem, - "child-channel", -}; - -/* grpc_child_channel proper */ - -#define LINK_BACK_ELEM_FROM_CHANNEL(channel) \ - grpc_channel_stack_element((channel), 0) - -#define LINK_BACK_ELEM_FROM_CALL(call) grpc_call_stack_element((call), 0) - -static void finally_destroy_channel(void *c, int success) { - /* ignore success or not... this is a destruction callback and will only - happen once - the only purpose here is to release resources */ - grpc_child_channel *channel = c; - lb_channel_data *chand = LINK_BACK_ELEM_FROM_CHANNEL(channel)->channel_data; - /* wait for the initiator to leave the mutex */ - gpr_mu_lock(&chand->mu); - gpr_mu_unlock(&chand->mu); - grpc_channel_stack_destroy(channel); - gpr_free(channel); -} - -static void send_farewells(void *c, int success) { - grpc_child_channel *channel = c; - grpc_channel_element *lbelem = LINK_BACK_ELEM_FROM_CHANNEL(channel); - lb_channel_data *chand = lbelem->channel_data; - int send_goaway; - grpc_channel_op op; - - gpr_mu_lock(&chand->mu); - send_goaway = !chand->sent_goaway; - chand->sent_goaway = 1; - gpr_mu_unlock(&chand->mu); - - if (send_goaway) { - op.type = GRPC_CHANNEL_GOAWAY; - op.dir = GRPC_CALL_DOWN; - op.data.goaway.status = GRPC_STATUS_OK; - op.data.goaway.message = gpr_slice_from_copied_string("Client disconnect"); - grpc_channel_next_op(lbelem, &op); - } - - op.type = GRPC_CHANNEL_DISCONNECT; - op.dir = GRPC_CALL_DOWN; - grpc_channel_next_op(lbelem, &op); - - gpr_mu_lock(&chand->mu); - chand->sending_farewell = 0; - chand->sent_farewell = 1; - maybe_destroy_channel(channel); - gpr_mu_unlock(&chand->mu); -} - -static void maybe_destroy_channel(grpc_child_channel *channel) { - lb_channel_data *chand = LINK_BACK_ELEM_FROM_CHANNEL(channel)->channel_data; - if (chand->destroyed && chand->disconnected && chand->active_calls == 0 && - !chand->sending_farewell && !chand->calling_back) { - chand->finally_destroy_channel_closure.cb = finally_destroy_channel; - chand->finally_destroy_channel_closure.cb_arg = channel; - grpc_iomgr_add_callback(&chand->finally_destroy_channel_closure); - } else if (chand->destroyed && !chand->disconnected && - chand->active_calls == 0 && !chand->sending_farewell && - !chand->sent_farewell) { - chand->sending_farewell = 1; - chand->send_farewells_closure.cb = send_farewells; - chand->send_farewells_closure.cb_arg = channel; - grpc_iomgr_add_callback(&chand->send_farewells_closure); - } -} - -grpc_child_channel *grpc_child_channel_create( - grpc_channel_element *parent, const grpc_channel_filter **filters, - size_t filter_count, const grpc_channel_args *args, - grpc_mdctx *metadata_context) { - grpc_channel_stack *stk = - gpr_malloc(grpc_channel_stack_size(filters, filter_count)); - lb_channel_data *lb; - - grpc_channel_stack_init(filters, filter_count, args, metadata_context, stk); - - lb = LINK_BACK_ELEM_FROM_CHANNEL(stk)->channel_data; - gpr_mu_lock(&lb->mu); - lb->back = parent; - gpr_mu_unlock(&lb->mu); - - return stk; -} - -void grpc_child_channel_destroy(grpc_child_channel *channel, - int wait_for_callbacks) { - grpc_channel_element *lbelem = LINK_BACK_ELEM_FROM_CHANNEL(channel); - lb_channel_data *chand = lbelem->channel_data; - - gpr_mu_lock(&chand->mu); - while (wait_for_callbacks && chand->calling_back) { - gpr_cv_wait(&chand->cv, &chand->mu, gpr_inf_future); - } - - chand->back = NULL; - chand->destroyed = 1; - maybe_destroy_channel(channel); - gpr_mu_unlock(&chand->mu); -} - -void grpc_child_channel_handle_op(grpc_child_channel *channel, - grpc_channel_op *op) { - grpc_channel_next_op(LINK_BACK_ELEM_FROM_CHANNEL(channel), op); -} - -grpc_child_call *grpc_child_channel_create_call(grpc_child_channel *channel, - grpc_call_element *parent, - grpc_transport_op *initial_op) { - grpc_call_stack *stk = gpr_malloc((channel)->call_stack_size); - grpc_call_element *lbelem; - lb_call_data *lbcalld; - lb_channel_data *lbchand; - - grpc_call_stack_init(channel, NULL, initial_op, stk); - lbelem = LINK_BACK_ELEM_FROM_CALL(stk); - lbchand = lbelem->channel_data; - lbcalld = lbelem->call_data; - lbcalld->channel = channel; - - gpr_mu_lock(&lbchand->mu); - lbchand->active_calls++; - gpr_mu_unlock(&lbchand->mu); - - return stk; -} - -void grpc_child_call_destroy(grpc_child_call *call) { - grpc_call_element *lbelem = LINK_BACK_ELEM_FROM_CALL(call); - lb_call_data *calld = lbelem->call_data; - lb_channel_data *chand = lbelem->channel_data; - grpc_child_channel *channel = calld->channel; - grpc_call_stack_destroy(call); - gpr_free(call); - gpr_mu_lock(&chand->mu); - chand->active_calls--; - maybe_destroy_channel(channel); - gpr_mu_unlock(&chand->mu); -} - -grpc_call_element *grpc_child_call_get_top_element(grpc_child_call *call) { - return LINK_BACK_ELEM_FROM_CALL(call); -} diff --git a/src/core/channel/child_channel.h b/src/core/channel/child_channel.h deleted file mode 100644 index 556a1c731ce..00000000000 --- a/src/core/channel/child_channel.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_INTERNAL_CORE_CHANNEL_CHILD_CHANNEL_H -#define GRPC_INTERNAL_CORE_CHANNEL_CHILD_CHANNEL_H - -#include "src/core/channel/channel_stack.h" - -/* helper for filters that need to host child channel stacks... handles - lifetime and upwards propagation cleanly */ - -extern const grpc_channel_filter grpc_child_channel_top_filter; - -typedef grpc_channel_stack grpc_child_channel; -typedef grpc_call_stack grpc_child_call; - -/* filters[0] must be &grpc_child_channel_top_filter */ -grpc_child_channel *grpc_child_channel_create( - grpc_channel_element *parent, const grpc_channel_filter **filters, - size_t filter_count, const grpc_channel_args *args, - grpc_mdctx *metadata_context); -void grpc_child_channel_handle_op(grpc_child_channel *channel, - grpc_channel_op *op); -grpc_channel_element *grpc_child_channel_get_bottom_element( - grpc_child_channel *channel); -void grpc_child_channel_destroy(grpc_child_channel *channel, - int wait_for_callbacks); - -grpc_child_call *grpc_child_channel_create_call(grpc_child_channel *channel, - grpc_call_element *parent, - grpc_transport_op *initial_op); -grpc_call_element *grpc_child_call_get_top_element(grpc_child_call *call); -void grpc_child_call_destroy(grpc_child_call *call); - -#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHILD_CHANNEL_H */ diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 726196e9968..ea79d539ec2 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -36,7 +36,6 @@ #include #include "src/core/channel/channel_args.h" -#include "src/core/channel/child_channel.h" #include "src/core/channel/connected_channel.h" #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/pollset_set.h" @@ -51,26 +50,25 @@ typedef struct call_data call_data; typedef struct { - /* protects children, child_count, child_capacity, active_child, - transport_setup_initiated - does not protect channel stacks held by children - transport_setup is assumed to be set once during construction */ - gpr_mu mu; - - /* the sending child (may be null) */ - grpc_child_channel *active_child; + /** metadata context for this channel */ grpc_mdctx *mdctx; + /** resolver for this channel */ + grpc_resolver *resolver; + /** channel arguments for this channel + TODO(ctiller): still needed? */ + grpc_channel_args *args; - /* calls waiting for a channel to be ready */ - call_data **waiting_children; - size_t waiting_child_count; - size_t waiting_child_capacity; + /** mutex protecting waiting list */ + gpr_mu mu_waiting; + /** mutex protecting client configuration, resolution state */ + gpr_mu mu_config; - /* transport setup for this channel */ - grpc_transport_setup *transport_setup; - int transport_setup_initiated; + /** currently active load balancer - guarded by mu_config */ + grpc_lb_policy *lb_policy; - grpc_channel_args *args; + /** incoming configuration - set by resolver.next + guarded by mu_config */ + grpc_client_config *incoming_configuration; } channel_data; typedef enum { @@ -84,12 +82,14 @@ struct call_data { /* owning element */ grpc_call_element *elem; + gpr_mu mu_state; + call_state state; gpr_timespec deadline; union { struct { /* our child call stack */ - grpc_child_call *child_call; + grpc_subchannel_call *subchannel_call; } active; grpc_transport_op waiting_op; struct { @@ -99,6 +99,7 @@ struct call_data { } s; }; +#if 0 static int prepare_activate(grpc_call_element *elem, grpc_child_channel *on_child) { call_data *calld = elem->call_data; @@ -150,6 +151,7 @@ static void remove_waiting_child(channel_data *chand, call_data *calld) { new_count == chand->waiting_child_count); chand->waiting_child_count = new_count; } +#endif static void handle_op_after_cancellation(grpc_call_element *elem, grpc_transport_op *op) { @@ -183,15 +185,99 @@ static void handle_op_after_cancellation(grpc_call_element *elem, } } +static void add_to_lb_policy_wait_queue_locked_state_config(channel_data *chand, call_data *calld) { + abort(); +} + +static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { + abort(); +} + static void cc_start_transport_op(grpc_call_element *elem, grpc_transport_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; - grpc_call_element *child_elem; + grpc_subchannel_call *subchannel_call; + grpc_lb_policy *lb_policy; grpc_transport_op waiting_op; GPR_ASSERT(elem->filter == &grpc_client_channel_filter); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); + gpr_mu_lock(&calld->mu_state); + switch (calld->state) { + case CALL_ACTIVE: + subchannel_call = calld->s.active.subchannel_call; + grpc_subchannel_call_ref(subchannel_call); + gpr_mu_unlock(&calld->mu_state); + grpc_subchannel_call_process_op(subchannel_call, op); + grpc_subchannel_call_unref(subchannel_call); + break; + case CALL_CANCELLED: + gpr_mu_unlock(&calld->mu_state); + handle_op_after_cancellation(elem, op); + break; + case CALL_CREATED: + if (op->cancel_with_status != GRPC_STATUS_OK) { + calld->state = CALL_CANCELLED; + gpr_mu_unlock(&calld->mu_state); + handle_op_after_cancellation(elem, op); + } else { + calld->state = CALL_WAITING; + calld->s.waiting_op = *op; + + gpr_mu_lock(&chand->mu_config); + lb_policy = chand->lb_policy; + if (lb_policy) { + grpc_lb_policy_ref(lb_policy); + gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&calld->mu_state); + + pick_target(lb_policy, calld); + + grpc_lb_policy_unref(lb_policy); + } else { + add_to_lb_policy_wait_queue_locked_state_config(chand, calld); + gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&calld->mu_state); + } + } + break; + case CALL_WAITING: + if (op->cancel_with_status != GRPC_STATUS_OK) { + waiting_op = calld->s.waiting_op; + calld->state = CALL_CANCELLED; + gpr_mu_unlock(&calld->mu_state); + handle_op_after_cancellation(elem, &waiting_op); + handle_op_after_cancellation(elem, op); + } else { + GPR_ASSERT((calld->s.waiting_op.send_ops == NULL) != + (op->send_ops == NULL)); + GPR_ASSERT((calld->s.waiting_op.recv_ops == NULL) != + (op->recv_ops == NULL)); + if (op->send_ops) { + calld->s.waiting_op.send_ops = op->send_ops; + calld->s.waiting_op.is_last_send = op->is_last_send; + calld->s.waiting_op.on_done_send = op->on_done_send; + calld->s.waiting_op.send_user_data = op->send_user_data; + } + if (op->recv_ops) { + calld->s.waiting_op.recv_ops = op->recv_ops; + calld->s.waiting_op.recv_state = op->recv_state; + calld->s.waiting_op.on_done_recv = op->on_done_recv; + calld->s.waiting_op.recv_user_data = op->recv_user_data; + } + gpr_mu_unlock(&calld->mu_state); + if (op->on_consumed) { + op->on_consumed(op->on_consumed_user_data, 0); + } + } + break; + } + + + + +#if 0 gpr_mu_lock(&chand->mu); switch (calld->state) { case CALL_ACTIVE: @@ -285,6 +371,7 @@ static void cc_start_transport_op(grpc_call_element *elem, handle_op_after_cancellation(elem, op); break; } +#endif } static void channel_op(grpc_channel_element *elem, @@ -536,11 +623,12 @@ grpc_transport_setup_result grpc_client_channel_transport_setup_complete( return result; } -void grpc_client_channel_set_transport_setup(grpc_channel_stack *channel_stack, - grpc_transport_setup *setup) { +void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, + grpc_resolver *resolver) { /* post construction initialization: set the transport setup pointer */ grpc_channel_element *elem = grpc_channel_stack_last_element(channel_stack); channel_data *chand = elem->channel_data; - GPR_ASSERT(!chand->transport_setup); - chand->transport_setup = setup; + GPR_ASSERT(!chand->resolver); + chand->resolver = resolver; + grpc_resolver_next(resolver, &chand->incoming_configuration, &chand->on_config_changed); } diff --git a/src/core/channel/client_channel.h b/src/core/channel/client_channel.h index 7a67a9f21f0..da02073353f 100644 --- a/src/core/channel/client_channel.h +++ b/src/core/channel/client_channel.h @@ -35,6 +35,7 @@ #define GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H #include "src/core/channel/channel_stack.h" +#include "src/core/client_config/resolver.h" /* A client channel is a channel that begins disconnected, and can connect to some endpoint on demand. If that endpoint disconnects, it will be @@ -48,8 +49,8 @@ extern const grpc_channel_filter grpc_client_channel_filter; /* post-construction initializer to let the client channel know which transport setup it should cancel upon destruction, or initiate when it needs a connection */ -void grpc_client_channel_set_transport_setup(grpc_channel_stack *channel_stack, - grpc_transport_setup *setup); +void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, + grpc_resolver *resolver); /* grpc_transport_setup_callback for binding new transports into a client channel - user_data should be the channel stack containing the client diff --git a/src/core/channel/client_setup.c b/src/core/channel/client_setup.c deleted file mode 100644 index 5be8fa66e99..00000000000 --- a/src/core/channel/client_setup.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/channel/client_setup.h" -#include "src/core/channel/channel_args.h" -#include "src/core/channel/channel_stack.h" -#include "src/core/iomgr/alarm.h" -#include -#include -#include - -struct grpc_client_setup { - grpc_transport_setup base; /* must be first */ - void (*initiate)(void *user_data, grpc_client_setup_request *request); - void (*done)(void *user_data); - void *user_data; - grpc_channel_args *args; - grpc_mdctx *mdctx; - grpc_alarm backoff_alarm; - gpr_timespec current_backoff_interval; - int in_alarm; - int in_cb; - int cancelled; - - gpr_mu mu; - gpr_cv cv; - grpc_client_setup_request *active_request; - int refs; - /** The set of pollsets that are currently interested in this - connection being established */ - grpc_pollset_set interested_parties; -}; - -struct grpc_client_setup_request { - /* pointer back to the setup object */ - grpc_client_setup *setup; - gpr_timespec deadline; -}; - -gpr_timespec grpc_client_setup_request_deadline(grpc_client_setup_request *r) { - return r->deadline; -} - -grpc_pollset_set *grpc_client_setup_get_interested_parties( - grpc_client_setup_request *r) { - return &r->setup->interested_parties; -} - -static void destroy_setup(grpc_client_setup *s) { - gpr_mu_destroy(&s->mu); - gpr_cv_destroy(&s->cv); - s->done(s->user_data); - grpc_channel_args_destroy(s->args); - grpc_pollset_set_destroy(&s->interested_parties); - gpr_free(s); -} - -static void destroy_request(grpc_client_setup_request *r) { gpr_free(r); } - -/* initiate handshaking */ -static void setup_initiate(grpc_transport_setup *sp) { - grpc_client_setup *s = (grpc_client_setup *)sp; - grpc_client_setup_request *r = gpr_malloc(sizeof(grpc_client_setup_request)); - int in_alarm = 0; - - r->setup = s; - r->deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(60)); - - gpr_mu_lock(&s->mu); - GPR_ASSERT(s->refs > 0); - /* there might be more than one request outstanding if the caller calls - initiate in some kind of rapid-fire way: we try to connect each time, - and keep track of the latest request (which is the only one that gets - to finish) */ - if (!s->in_alarm) { - s->active_request = r; - s->refs++; - } else { - /* TODO(klempner): Maybe do something more clever here */ - in_alarm = 1; - } - gpr_mu_unlock(&s->mu); - - if (!in_alarm) { - s->initiate(s->user_data, r); - } else { - destroy_request(r); - } -} - -/** implementation of add_interested_party for setup vtable */ -static void setup_add_interested_party(grpc_transport_setup *sp, - grpc_pollset *pollset) { - grpc_client_setup *s = (grpc_client_setup *)sp; - - gpr_mu_lock(&s->mu); - grpc_pollset_set_add_pollset(&s->interested_parties, pollset); - gpr_mu_unlock(&s->mu); -} - -/** implementation of del_interested_party for setup vtable */ -static void setup_del_interested_party(grpc_transport_setup *sp, - grpc_pollset *pollset) { - grpc_client_setup *s = (grpc_client_setup *)sp; - - gpr_mu_lock(&s->mu); - grpc_pollset_set_del_pollset(&s->interested_parties, pollset); - gpr_mu_unlock(&s->mu); -} - -/* cancel handshaking: cancel all requests, and shutdown (the caller promises - not to initiate again) */ -static void setup_cancel(grpc_transport_setup *sp) { - grpc_client_setup *s = (grpc_client_setup *)sp; - int cancel_alarm = 0; - - gpr_mu_lock(&s->mu); - s->cancelled = 1; - while (s->in_cb) { - gpr_cv_wait(&s->cv, &s->mu, gpr_inf_future); - } - - GPR_ASSERT(s->refs > 0); - /* effectively cancels the current request (if any) */ - s->active_request = NULL; - if (s->in_alarm) { - cancel_alarm = 1; - } - if (--s->refs == 0) { - gpr_mu_unlock(&s->mu); - destroy_setup(s); - } else { - gpr_mu_unlock(&s->mu); - } - if (cancel_alarm) { - grpc_alarm_cancel(&s->backoff_alarm); - } -} - -int grpc_client_setup_cb_begin(grpc_client_setup_request *r, - const char *reason) { - gpr_mu_lock(&r->setup->mu); - if (r->setup->cancelled) { - gpr_mu_unlock(&r->setup->mu); - return 0; - } - r->setup->in_cb++; - gpr_mu_unlock(&r->setup->mu); - return 1; -} - -void grpc_client_setup_cb_end(grpc_client_setup_request *r, - const char *reason) { - gpr_mu_lock(&r->setup->mu); - r->setup->in_cb--; - if (r->setup->cancelled) gpr_cv_signal(&r->setup->cv); - gpr_mu_unlock(&r->setup->mu); -} - -/* vtable for transport setup */ -static const grpc_transport_setup_vtable setup_vtable = { - setup_initiate, setup_add_interested_party, setup_del_interested_party, - setup_cancel}; - -void grpc_client_setup_create_and_attach( - grpc_channel_stack *newly_minted_channel, const grpc_channel_args *args, - grpc_mdctx *mdctx, - void (*initiate)(void *user_data, grpc_client_setup_request *request), - void (*done)(void *user_data), void *user_data) { - grpc_client_setup *s = gpr_malloc(sizeof(grpc_client_setup)); - - s->base.vtable = &setup_vtable; - gpr_mu_init(&s->mu); - gpr_cv_init(&s->cv); - s->refs = 1; - s->mdctx = mdctx; - s->initiate = initiate; - s->done = done; - s->user_data = user_data; - s->active_request = NULL; - s->args = grpc_channel_args_copy(args); - s->current_backoff_interval = gpr_time_from_micros(1000000); - s->in_alarm = 0; - s->in_cb = 0; - s->cancelled = 0; - grpc_pollset_set_init(&s->interested_parties); - - grpc_client_channel_set_transport_setup(newly_minted_channel, &s->base); -} - -int grpc_client_setup_request_should_continue(grpc_client_setup_request *r, - const char *reason) { - int result; - if (gpr_time_cmp(gpr_now(), r->deadline) > 0) { - result = 0; - } else { - gpr_mu_lock(&r->setup->mu); - result = r->setup->active_request == r; - gpr_mu_unlock(&r->setup->mu); - } - return result; -} - -static void backoff_alarm_done(void *arg /* grpc_client_setup_request */, - int success) { - grpc_client_setup_request *r = arg; - grpc_client_setup *s = r->setup; - /* Handle status cancelled? */ - gpr_mu_lock(&s->mu); - s->in_alarm = 0; - if (s->active_request != NULL || !success) { - if (0 == --s->refs) { - gpr_mu_unlock(&s->mu); - destroy_setup(s); - destroy_request(r); - return; - } else { - gpr_mu_unlock(&s->mu); - destroy_request(r); - return; - } - } - s->active_request = r; - gpr_mu_unlock(&s->mu); - s->initiate(s->user_data, r); -} - -void grpc_client_setup_request_finish(grpc_client_setup_request *r, - int was_successful) { - int retry = !was_successful; - grpc_client_setup *s = r->setup; - - gpr_mu_lock(&s->mu); - if (s->active_request == r) { - s->active_request = NULL; - } else { - retry = 0; - } - - if (!retry && 0 == --s->refs) { - gpr_mu_unlock(&s->mu); - destroy_setup(s); - destroy_request(r); - } else if (retry) { - /* TODO(klempner): Replace these values with further consideration. 2x is - probably too aggressive of a backoff. */ - gpr_timespec max_backoff = gpr_time_from_minutes(2); - gpr_timespec now = gpr_now(); - gpr_timespec deadline = gpr_time_add(s->current_backoff_interval, now); - GPR_ASSERT(!s->in_alarm); - s->in_alarm = 1; - grpc_alarm_init(&s->backoff_alarm, deadline, backoff_alarm_done, r, now); - s->current_backoff_interval = - gpr_time_add(s->current_backoff_interval, s->current_backoff_interval); - if (gpr_time_cmp(s->current_backoff_interval, max_backoff) > 0) { - s->current_backoff_interval = max_backoff; - } - gpr_mu_unlock(&s->mu); - } else { - gpr_mu_unlock(&s->mu); - destroy_request(r); - } -} - -const grpc_channel_args *grpc_client_setup_get_channel_args( - grpc_client_setup_request *r) { - return r->setup->args; -} - -grpc_mdctx *grpc_client_setup_get_mdctx(grpc_client_setup_request *r) { - return r->setup->mdctx; -} diff --git a/src/core/channel/client_setup.h b/src/core/channel/client_setup.h deleted file mode 100644 index 7d40338840b..00000000000 --- a/src/core/channel/client_setup.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_INTERNAL_CORE_CHANNEL_CLIENT_SETUP_H -#define GRPC_INTERNAL_CORE_CHANNEL_CLIENT_SETUP_H - -#include "src/core/channel/client_channel.h" -#include "src/core/transport/metadata.h" -#include - -/* Convenience API's to simplify transport setup */ - -typedef struct grpc_client_setup grpc_client_setup; -typedef struct grpc_client_setup_request grpc_client_setup_request; - -void grpc_client_setup_create_and_attach( - grpc_channel_stack *newly_minted_channel, const grpc_channel_args *args, - grpc_mdctx *mdctx, - void (*initiate)(void *user_data, grpc_client_setup_request *request), - void (*done)(void *user_data), void *user_data); - -/* Check that r is the active request: needs to be performed at each callback. - If this races, we'll have two connection attempts running at once and the - old one will get cleaned up in due course, which is fine. */ -int grpc_client_setup_request_should_continue(grpc_client_setup_request *r, - const char *reason); -void grpc_client_setup_request_finish(grpc_client_setup_request *r, - int was_successful); -const grpc_channel_args *grpc_client_setup_get_channel_args( - grpc_client_setup_request *r); - -/* Call before calling back into the setup listener, and call only if - this function returns 1. If it returns 1, also promise to call - grpc_client_setup_cb_end */ -int grpc_client_setup_cb_begin(grpc_client_setup_request *r, - const char *reason); -void grpc_client_setup_cb_end(grpc_client_setup_request *r, const char *reason); - -/* Get the deadline for a request passed in to initiate. Implementations should - make a best effort to honor this deadline. */ -gpr_timespec grpc_client_setup_request_deadline(grpc_client_setup_request *r); -grpc_pollset_set *grpc_client_setup_get_interested_parties( - grpc_client_setup_request *r); - -grpc_mdctx *grpc_client_setup_get_mdctx(grpc_client_setup_request *r); - -#endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_SETUP_H */ diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 0350d0cb538..0b21af4f699 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -56,6 +56,9 @@ struct grpc_lb_policy_vtable { grpc_iomgr_closure *on_complete); }; +void grpc_lb_policy_ref(grpc_lb_policy *policy); +void grpc_lb_policy_unref(grpc_lb_policy *policy); + /** Start shutting down (fail any pending picks) */ void grpc_lb_policy_shutdown(grpc_lb_policy *policy); diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index a10a75d6ac8..c87d294d8c3 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -34,6 +34,7 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H +#include "src/core/channel/channel_stack.h" #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/sockaddr.h" #include "src/core/transport/transport.h" @@ -41,6 +42,7 @@ /** A (sub-)channel that knows how to connect to exactly one target address. Provides a target for load balancing. */ typedef struct grpc_subchannel grpc_subchannel; +typedef struct grpc_subchannel_call grpc_subchannel_call; /** Connectivity state of a channel. TODO(ctiller): move to grpc.h when we implement the public @@ -61,6 +63,9 @@ typedef enum { void grpc_subchannel_ref(grpc_subchannel *channel); void grpc_subchannel_unref(grpc_subchannel *channel); +void grpc_subchannel_call_ref(grpc_subchannel_call *call); +void grpc_subchannel_call_unref(grpc_subchannel_call *call); + /** poll the current connectivity state of a channel */ grpc_connectivity_state grpc_subchannel_check_connectivity( grpc_subchannel *channel); @@ -71,8 +76,10 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, grpc_connectivity_state *state, grpc_iomgr_closure *notify); -/** continue processing of transport operation \a op */ -void grpc_subchannel_continue_op(grpc_subchannel *channel, - grpc_transport_op *op); +/** construct a call */ +grpc_subchannel_call *grpc_subchannel_create_call(grpc_subchannel *subchannel, grpc_call_element *parent, grpc_transport_op *initial_op); + +/** continue processing a transport op */ +void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, grpc_transport_op *op); #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H */ diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h index 58fa91e9767..516c0ac5596 100644 --- a/src/core/surface/channel.h +++ b/src/core/surface/channel.h @@ -44,11 +44,6 @@ grpc_channel *grpc_channel_create_from_filters( /** Get a (borrowed) pointer to this channels underlying channel stack */ grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel); -/** Get a (borrowed) pointer to this channels subchannel factory (if it exists) - */ -grpc_subchannel_factory *grpc_channel_get_subchannel_factory( - grpc_channel *channel); - /** Get a (borrowed) pointer to the channel wide metadata context */ grpc_mdctx *grpc_channel_get_metadata_context(grpc_channel *channel); diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index d069a04a9a8..8efd86b9f67 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -31,159 +31,16 @@ * */ -#include "src/core/iomgr/sockaddr.h" - #include #include #include -#include "src/core/channel/census_filter.h" -#include "src/core/channel/channel_args.h" #include "src/core/channel/client_channel.h" -#include "src/core/channel/client_setup.h" -#include "src/core/channel/connected_channel.h" -#include "src/core/channel/http_client_filter.h" -#include "src/core/iomgr/endpoint.h" -#include "src/core/iomgr/resolve_address.h" -#include "src/core/iomgr/tcp_client.h" +#include "src/core/client_config/resolver_registry.h" +#include "src/core/client_config/subchannels/tcp_subchannel.h" #include "src/core/surface/channel.h" #include "src/core/surface/client.h" -#include "src/core/support/string.h" -#include "src/core/transport/chttp2_transport.h" -#include -#include -#include -#include -#include - -typedef struct setup setup; - -/* A single setup request (started via initiate) */ -typedef struct { - grpc_client_setup_request *cs_request; - setup *setup; - /* Resolved addresses, or null if resolution not yet completed */ - grpc_resolved_addresses *resolved; - /* which address in resolved should we pick for the next connection attempt */ - size_t resolved_index; -} request; - -/* Global setup logic (may be running many simultaneous setup requests, but - with only one 'active' */ -struct setup { - const char *target; - grpc_transport_setup_callback setup_callback; - void *setup_user_data; -}; - -static int maybe_try_next_resolved(request *r); - -static void done(request *r, int was_successful) { - grpc_client_setup_request_finish(r->cs_request, was_successful); - if (r->resolved) { - grpc_resolved_addresses_destroy(r->resolved); - } - gpr_free(r); -} - -/* connection callback: tcp is either valid, or null on error */ -static void on_connect(void *rp, grpc_endpoint *tcp) { - request *r = rp; - - if (!grpc_client_setup_request_should_continue(r->cs_request, "on_connect")) { - if (tcp) { - grpc_endpoint_shutdown(tcp); - grpc_endpoint_destroy(tcp); - } - done(r, 0); - return; - } - - if (!tcp) { - if (!maybe_try_next_resolved(r)) { - done(r, 0); - return; - } else { - return; - } - } else if (grpc_client_setup_cb_begin(r->cs_request, "on_connect")) { - grpc_create_chttp2_transport( - r->setup->setup_callback, r->setup->setup_user_data, - grpc_client_setup_get_channel_args(r->cs_request), tcp, NULL, 0, - grpc_client_setup_get_mdctx(r->cs_request), 1); - grpc_client_setup_cb_end(r->cs_request, "on_connect"); - done(r, 1); - return; - } else { - done(r, 0); - } -} - -/* attempt to connect to the next available resolved address */ -static int maybe_try_next_resolved(request *r) { - grpc_resolved_address *addr; - if (!r->resolved) return 0; - if (r->resolved_index == r->resolved->naddrs) return 0; - addr = &r->resolved->addrs[r->resolved_index++]; - grpc_tcp_client_connect( - on_connect, r, grpc_client_setup_get_interested_parties(r->cs_request), - (struct sockaddr *)&addr->addr, addr->len, - grpc_client_setup_request_deadline(r->cs_request)); - return 1; -} - -/* callback for when our target address has been resolved */ -static void on_resolved(void *rp, grpc_resolved_addresses *resolved) { - request *r = rp; - - /* if we're not still the active request, abort */ - if (!grpc_client_setup_request_should_continue(r->cs_request, - "on_resolved")) { - if (resolved) { - grpc_resolved_addresses_destroy(resolved); - } - done(r, 0); - return; - } - - if (!resolved) { - done(r, 0); - return; - } else { - r->resolved = resolved; - r->resolved_index = 0; - if (!maybe_try_next_resolved(r)) { - done(r, 0); - } - } -} - -static void initiate_setup(void *sp, grpc_client_setup_request *cs_request) { - request *r = gpr_malloc(sizeof(request)); - r->setup = sp; - r->cs_request = cs_request; - r->resolved = NULL; - r->resolved_index = 0; - /* TODO(klempner): Make grpc_resolve_address respect deadline */ - grpc_resolve_address(r->setup->target, "http", on_resolved, r); -} - -static void done_setup(void *sp) { - setup *s = sp; - gpr_free((void *)s->target); - gpr_free(s); -} - -static grpc_transport_setup_result complete_setup(void *channel_stack, - grpc_transport *transport, - grpc_mdctx *mdctx) { - static grpc_channel_filter const *extra_filters[] = { - &grpc_http_client_filter}; - return grpc_client_channel_transport_setup_complete( - channel_stack, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), - mdctx); -} /* Create a client channel: Asynchronously: - resolve target @@ -191,11 +48,10 @@ static grpc_transport_setup_result complete_setup(void *channel_stack, - perform handshakes */ grpc_channel *grpc_channel_create(const char *target, const grpc_channel_args *args) { - setup *s = gpr_malloc(sizeof(setup)); - grpc_mdctx *mdctx = grpc_mdctx_create(); grpc_channel *channel = NULL; #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; + grpc_resolver *resolver; int n = 0; filters[n++] = &grpc_client_surface_filter; /* TODO(census) @@ -204,15 +60,14 @@ grpc_channel *grpc_channel_create(const char *target, } */ filters[n++] = &grpc_client_channel_filter; GPR_ASSERT(n <= MAX_FILTERS); - channel = grpc_channel_create_from_filters(filters, n, args, mdctx, 1); - s->target = gpr_strdup(target); - s->setup_callback = complete_setup; - s->setup_user_data = grpc_channel_get_channel_stack(channel); + resolver = grpc_resolver_create(target, grpc_create_tcp_subchannel_factory()); + if (!resolver) { + return NULL; + } - grpc_client_setup_create_and_attach(grpc_channel_get_channel_stack(channel), - args, mdctx, initiate_setup, done_setup, - s); + channel = grpc_channel_create_from_filters(filters, n, args, grpc_mdctx_create(), 1); + grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); return channel; } diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index cf72f7ada54..e6af18d6159 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -760,7 +760,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = include/grpc/grpc_security.h include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h include/grpc/grpc.h include/grpc/status.h include/grpc/census.h src/core/httpcli/format_request.h src/core/httpcli/httpcli.h src/core/httpcli/httpcli_security_connector.h src/core/httpcli/parser.h src/core/security/auth_filters.h src/core/security/base64.h src/core/security/credentials.h src/core/security/json_token.h src/core/security/secure_endpoint.h src/core/security/secure_transport_setup.h src/core/security/security_connector.h src/core/security/security_context.h src/core/tsi/fake_transport_security.h src/core/tsi/ssl_transport_security.h src/core/tsi/transport_security.h src/core/tsi/transport_security_interface.h src/core/census/grpc_context.h src/core/channel/census_filter.h src/core/channel/channel_args.h src/core/channel/channel_stack.h src/core/channel/child_channel.h src/core/channel/client_channel.h src/core/channel/client_setup.h src/core/channel/connected_channel.h src/core/channel/context.h src/core/channel/http_client_filter.h src/core/channel/http_server_filter.h src/core/channel/noop_filter.h src/core/client_config/client_config.h src/core/client_config/lb_policies/pick_first.h src/core/client_config/lb_policy.h src/core/client_config/resolver.h src/core/client_config/resolver_factory.h src/core/client_config/resolver_registry.h src/core/client_config/resolvers/dns_resolver.h src/core/client_config/subchannel.h src/core/client_config/subchannel_factory.h src/core/client_config/uri_parser.h src/core/compression/message_compress.h src/core/debug/trace.h src/core/iomgr/alarm.h src/core/iomgr/alarm_heap.h src/core/iomgr/alarm_internal.h src/core/iomgr/endpoint.h src/core/iomgr/endpoint_pair.h src/core/iomgr/fd_posix.h src/core/iomgr/iocp_windows.h src/core/iomgr/iomgr.h src/core/iomgr/iomgr_internal.h src/core/iomgr/iomgr_posix.h src/core/iomgr/pollset.h src/core/iomgr/pollset_kick_posix.h src/core/iomgr/pollset_posix.h src/core/iomgr/pollset_set.h src/core/iomgr/pollset_set_posix.h src/core/iomgr/pollset_set_windows.h src/core/iomgr/pollset_windows.h src/core/iomgr/resolve_address.h src/core/iomgr/sockaddr.h src/core/iomgr/sockaddr_posix.h src/core/iomgr/sockaddr_utils.h src/core/iomgr/sockaddr_win32.h src/core/iomgr/socket_utils_posix.h src/core/iomgr/socket_windows.h src/core/iomgr/tcp_client.h src/core/iomgr/tcp_posix.h src/core/iomgr/tcp_server.h src/core/iomgr/tcp_windows.h src/core/iomgr/time_averaged_stats.h src/core/iomgr/wakeup_fd_pipe.h src/core/iomgr/wakeup_fd_posix.h src/core/json/json.h src/core/json/json_common.h src/core/json/json_reader.h src/core/json/json_writer.h src/core/profiling/timers.h src/core/profiling/timers_preciseclock.h src/core/surface/byte_buffer_queue.h src/core/surface/call.h src/core/surface/channel.h src/core/surface/client.h src/core/surface/completion_queue.h src/core/surface/event_string.h src/core/surface/init.h src/core/surface/server.h src/core/surface/surface_trace.h src/core/transport/chttp2/alpn.h src/core/transport/chttp2/bin_encoder.h src/core/transport/chttp2/frame.h src/core/transport/chttp2/frame_data.h src/core/transport/chttp2/frame_goaway.h src/core/transport/chttp2/frame_ping.h src/core/transport/chttp2/frame_rst_stream.h src/core/transport/chttp2/frame_settings.h src/core/transport/chttp2/frame_window_update.h src/core/transport/chttp2/hpack_parser.h src/core/transport/chttp2/hpack_table.h src/core/transport/chttp2/http2_errors.h src/core/transport/chttp2/huffsyms.h src/core/transport/chttp2/status_conversion.h src/core/transport/chttp2/stream_encoder.h src/core/transport/chttp2/stream_map.h src/core/transport/chttp2/timeout_encoding.h src/core/transport/chttp2/varint.h src/core/transport/chttp2_transport.h src/core/transport/metadata.h src/core/transport/stream_op.h src/core/transport/transport.h src/core/transport/transport_impl.h src/core/census/context.h src/core/httpcli/format_request.c src/core/httpcli/httpcli.c src/core/httpcli/httpcli_security_connector.c src/core/httpcli/parser.c src/core/security/base64.c src/core/security/client_auth_filter.c src/core/security/credentials.c src/core/security/credentials_metadata.c src/core/security/credentials_posix.c src/core/security/credentials_win32.c src/core/security/google_default_credentials.c src/core/security/json_token.c src/core/security/secure_endpoint.c src/core/security/secure_transport_setup.c src/core/security/security_connector.c src/core/security/security_context.c src/core/security/server_auth_filter.c src/core/security/server_secure_chttp2.c src/core/surface/init_secure.c src/core/surface/secure_channel_create.c src/core/tsi/fake_transport_security.c src/core/tsi/ssl_transport_security.c src/core/tsi/transport_security.c src/core/census/grpc_context.c src/core/channel/channel_args.c src/core/channel/channel_stack.c src/core/channel/child_channel.c src/core/channel/client_channel.c src/core/channel/client_setup.c src/core/channel/connected_channel.c src/core/channel/http_client_filter.c src/core/channel/http_server_filter.c src/core/channel/noop_filter.c src/core/client_config/client_config.c src/core/client_config/lb_policies/pick_first.c src/core/client_config/lb_policy.c src/core/client_config/resolver.c src/core/client_config/resolver_factory.c src/core/client_config/resolver_registry.c src/core/client_config/resolvers/dns_resolver.c src/core/client_config/subchannel.c src/core/client_config/subchannel_factory.c src/core/client_config/uri_parser.c src/core/compression/algorithm.c src/core/compression/message_compress.c src/core/debug/trace.c src/core/iomgr/alarm.c src/core/iomgr/alarm_heap.c src/core/iomgr/endpoint.c src/core/iomgr/endpoint_pair_posix.c src/core/iomgr/endpoint_pair_windows.c src/core/iomgr/fd_posix.c src/core/iomgr/iocp_windows.c src/core/iomgr/iomgr.c src/core/iomgr/iomgr_posix.c src/core/iomgr/iomgr_windows.c src/core/iomgr/pollset_kick_posix.c src/core/iomgr/pollset_multipoller_with_epoll.c src/core/iomgr/pollset_multipoller_with_poll_posix.c src/core/iomgr/pollset_posix.c src/core/iomgr/pollset_set_posix.c src/core/iomgr/pollset_set_windows.c src/core/iomgr/pollset_windows.c src/core/iomgr/resolve_address_posix.c src/core/iomgr/resolve_address_windows.c src/core/iomgr/sockaddr_utils.c src/core/iomgr/socket_utils_common_posix.c src/core/iomgr/socket_utils_linux.c src/core/iomgr/socket_utils_posix.c src/core/iomgr/socket_windows.c src/core/iomgr/tcp_client_posix.c src/core/iomgr/tcp_client_windows.c src/core/iomgr/tcp_posix.c src/core/iomgr/tcp_server_posix.c src/core/iomgr/tcp_server_windows.c src/core/iomgr/tcp_windows.c src/core/iomgr/time_averaged_stats.c src/core/iomgr/wakeup_fd_eventfd.c src/core/iomgr/wakeup_fd_nospecial.c src/core/iomgr/wakeup_fd_pipe.c src/core/iomgr/wakeup_fd_posix.c src/core/json/json.c src/core/json/json_reader.c src/core/json/json_string.c src/core/json/json_writer.c src/core/profiling/basic_timers.c src/core/profiling/stap_timers.c src/core/surface/byte_buffer.c src/core/surface/byte_buffer_queue.c src/core/surface/byte_buffer_reader.c src/core/surface/call.c src/core/surface/call_details.c src/core/surface/call_log_batch.c src/core/surface/channel.c src/core/surface/channel_create.c src/core/surface/client.c src/core/surface/completion_queue.c src/core/surface/event_string.c src/core/surface/init.c src/core/surface/lame_client.c src/core/surface/metadata_array.c src/core/surface/server.c src/core/surface/server_chttp2.c src/core/surface/server_create.c src/core/surface/surface_trace.c src/core/transport/chttp2/alpn.c src/core/transport/chttp2/bin_encoder.c src/core/transport/chttp2/frame_data.c src/core/transport/chttp2/frame_goaway.c src/core/transport/chttp2/frame_ping.c src/core/transport/chttp2/frame_rst_stream.c src/core/transport/chttp2/frame_settings.c src/core/transport/chttp2/frame_window_update.c src/core/transport/chttp2/hpack_parser.c src/core/transport/chttp2/hpack_table.c src/core/transport/chttp2/huffsyms.c src/core/transport/chttp2/status_conversion.c src/core/transport/chttp2/stream_encoder.c src/core/transport/chttp2/stream_map.c src/core/transport/chttp2/timeout_encoding.c src/core/transport/chttp2/varint.c src/core/transport/chttp2_transport.c src/core/transport/metadata.c src/core/transport/stream_op.c src/core/transport/transport.c src/core/transport/transport_op_string.c src/core/census/context.c src/core/census/initialize.c include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_win32.h include/grpc/support/cancellable_platform.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/histogram.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_win32.h include/grpc/support/port_platform.h include/grpc/support/slice.h include/grpc/support/slice_buffer.h include/grpc/support/string_util.h include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h include/grpc/support/sync_win32.h include/grpc/support/thd.h include/grpc/support/time.h include/grpc/support/tls.h include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h include/grpc/support/useful.h src/core/support/env.h src/core/support/file.h src/core/support/murmur_hash.h src/core/support/string.h src/core/support/string_win32.h src/core/support/thd_internal.h src/core/support/alloc.c src/core/support/cancellable.c src/core/support/cmdline.c src/core/support/cpu_iphone.c src/core/support/cpu_linux.c src/core/support/cpu_posix.c src/core/support/cpu_windows.c src/core/support/env_linux.c src/core/support/env_posix.c src/core/support/env_win32.c src/core/support/file.c src/core/support/file_posix.c src/core/support/file_win32.c src/core/support/histogram.c src/core/support/host_port.c src/core/support/log.c src/core/support/log_android.c src/core/support/log_linux.c src/core/support/log_posix.c src/core/support/log_win32.c src/core/support/murmur_hash.c src/core/support/slice.c src/core/support/slice_buffer.c src/core/support/string.c src/core/support/string_posix.c src/core/support/string_win32.c src/core/support/subprocess_posix.c src/core/support/sync.c src/core/support/sync_posix.c src/core/support/sync_win32.c src/core/support/thd.c src/core/support/thd_posix.c src/core/support/thd_win32.c src/core/support/time.c src/core/support/time_posix.c src/core/support/time_win32.c src/core/support/tls_pthread.c +INPUT = include/grpc/grpc_security.h include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h include/grpc/grpc.h include/grpc/status.h include/grpc/census.h src/core/httpcli/format_request.h src/core/httpcli/httpcli.h src/core/httpcli/httpcli_security_connector.h src/core/httpcli/parser.h src/core/security/auth_filters.h src/core/security/base64.h src/core/security/credentials.h src/core/security/json_token.h src/core/security/secure_endpoint.h src/core/security/secure_transport_setup.h src/core/security/security_connector.h src/core/security/security_context.h src/core/tsi/fake_transport_security.h src/core/tsi/ssl_transport_security.h src/core/tsi/transport_security.h src/core/tsi/transport_security_interface.h src/core/census/grpc_context.h src/core/channel/census_filter.h src/core/channel/channel_args.h src/core/channel/channel_stack.h src/core/channel/client_channel.h src/core/channel/connected_channel.h src/core/channel/context.h src/core/channel/http_client_filter.h src/core/channel/http_server_filter.h src/core/channel/noop_filter.h src/core/client_config/client_config.h src/core/client_config/lb_policies/pick_first.h src/core/client_config/lb_policy.h src/core/client_config/resolver.h src/core/client_config/resolver_factory.h src/core/client_config/resolver_registry.h src/core/client_config/resolvers/dns_resolver.h src/core/client_config/subchannel.h src/core/client_config/subchannel_factory.h src/core/client_config/uri_parser.h src/core/compression/message_compress.h src/core/debug/trace.h src/core/iomgr/alarm.h src/core/iomgr/alarm_heap.h src/core/iomgr/alarm_internal.h src/core/iomgr/endpoint.h src/core/iomgr/endpoint_pair.h src/core/iomgr/fd_posix.h src/core/iomgr/iocp_windows.h src/core/iomgr/iomgr.h src/core/iomgr/iomgr_internal.h src/core/iomgr/iomgr_posix.h src/core/iomgr/pollset.h src/core/iomgr/pollset_kick_posix.h src/core/iomgr/pollset_posix.h src/core/iomgr/pollset_set.h src/core/iomgr/pollset_set_posix.h src/core/iomgr/pollset_set_windows.h src/core/iomgr/pollset_windows.h src/core/iomgr/resolve_address.h src/core/iomgr/sockaddr.h src/core/iomgr/sockaddr_posix.h src/core/iomgr/sockaddr_utils.h src/core/iomgr/sockaddr_win32.h src/core/iomgr/socket_utils_posix.h src/core/iomgr/socket_windows.h src/core/iomgr/tcp_client.h src/core/iomgr/tcp_posix.h src/core/iomgr/tcp_server.h src/core/iomgr/tcp_windows.h src/core/iomgr/time_averaged_stats.h src/core/iomgr/wakeup_fd_pipe.h src/core/iomgr/wakeup_fd_posix.h src/core/json/json.h src/core/json/json_common.h src/core/json/json_reader.h src/core/json/json_writer.h src/core/profiling/timers.h src/core/profiling/timers_preciseclock.h src/core/surface/byte_buffer_queue.h src/core/surface/call.h src/core/surface/channel.h src/core/surface/client.h src/core/surface/completion_queue.h src/core/surface/event_string.h src/core/surface/init.h src/core/surface/server.h src/core/surface/surface_trace.h src/core/transport/chttp2/alpn.h src/core/transport/chttp2/bin_encoder.h src/core/transport/chttp2/frame.h src/core/transport/chttp2/frame_data.h src/core/transport/chttp2/frame_goaway.h src/core/transport/chttp2/frame_ping.h src/core/transport/chttp2/frame_rst_stream.h src/core/transport/chttp2/frame_settings.h src/core/transport/chttp2/frame_window_update.h src/core/transport/chttp2/hpack_parser.h src/core/transport/chttp2/hpack_table.h src/core/transport/chttp2/http2_errors.h src/core/transport/chttp2/huffsyms.h src/core/transport/chttp2/status_conversion.h src/core/transport/chttp2/stream_encoder.h src/core/transport/chttp2/stream_map.h src/core/transport/chttp2/timeout_encoding.h src/core/transport/chttp2/varint.h src/core/transport/chttp2_transport.h src/core/transport/metadata.h src/core/transport/stream_op.h src/core/transport/transport.h src/core/transport/transport_impl.h src/core/census/context.h src/core/httpcli/format_request.c src/core/httpcli/httpcli.c src/core/httpcli/httpcli_security_connector.c src/core/httpcli/parser.c src/core/security/base64.c src/core/security/client_auth_filter.c src/core/security/credentials.c src/core/security/credentials_metadata.c src/core/security/credentials_posix.c src/core/security/credentials_win32.c src/core/security/google_default_credentials.c src/core/security/json_token.c src/core/security/secure_endpoint.c src/core/security/secure_transport_setup.c src/core/security/security_connector.c src/core/security/security_context.c src/core/security/server_auth_filter.c src/core/security/server_secure_chttp2.c src/core/surface/init_secure.c src/core/surface/secure_channel_create.c src/core/tsi/fake_transport_security.c src/core/tsi/ssl_transport_security.c src/core/tsi/transport_security.c src/core/census/grpc_context.c src/core/channel/channel_args.c src/core/channel/channel_stack.c src/core/channel/client_channel.c src/core/channel/connected_channel.c src/core/channel/http_client_filter.c src/core/channel/http_server_filter.c src/core/channel/noop_filter.c src/core/client_config/client_config.c src/core/client_config/lb_policies/pick_first.c src/core/client_config/lb_policy.c src/core/client_config/resolver.c src/core/client_config/resolver_factory.c src/core/client_config/resolver_registry.c src/core/client_config/resolvers/dns_resolver.c src/core/client_config/subchannel.c src/core/client_config/subchannel_factory.c src/core/client_config/uri_parser.c src/core/compression/algorithm.c src/core/compression/message_compress.c src/core/debug/trace.c src/core/iomgr/alarm.c src/core/iomgr/alarm_heap.c src/core/iomgr/endpoint.c src/core/iomgr/endpoint_pair_posix.c src/core/iomgr/endpoint_pair_windows.c src/core/iomgr/fd_posix.c src/core/iomgr/iocp_windows.c src/core/iomgr/iomgr.c src/core/iomgr/iomgr_posix.c src/core/iomgr/iomgr_windows.c src/core/iomgr/pollset_kick_posix.c src/core/iomgr/pollset_multipoller_with_epoll.c src/core/iomgr/pollset_multipoller_with_poll_posix.c src/core/iomgr/pollset_posix.c src/core/iomgr/pollset_set_posix.c src/core/iomgr/pollset_set_windows.c src/core/iomgr/pollset_windows.c src/core/iomgr/resolve_address_posix.c src/core/iomgr/resolve_address_windows.c src/core/iomgr/sockaddr_utils.c src/core/iomgr/socket_utils_common_posix.c src/core/iomgr/socket_utils_linux.c src/core/iomgr/socket_utils_posix.c src/core/iomgr/socket_windows.c src/core/iomgr/tcp_client_posix.c src/core/iomgr/tcp_client_windows.c src/core/iomgr/tcp_posix.c src/core/iomgr/tcp_server_posix.c src/core/iomgr/tcp_server_windows.c src/core/iomgr/tcp_windows.c src/core/iomgr/time_averaged_stats.c src/core/iomgr/wakeup_fd_eventfd.c src/core/iomgr/wakeup_fd_nospecial.c src/core/iomgr/wakeup_fd_pipe.c src/core/iomgr/wakeup_fd_posix.c src/core/json/json.c src/core/json/json_reader.c src/core/json/json_string.c src/core/json/json_writer.c src/core/profiling/basic_timers.c src/core/profiling/stap_timers.c src/core/surface/byte_buffer.c src/core/surface/byte_buffer_queue.c src/core/surface/byte_buffer_reader.c src/core/surface/call.c src/core/surface/call_details.c src/core/surface/call_log_batch.c src/core/surface/channel.c src/core/surface/channel_create.c src/core/surface/client.c src/core/surface/completion_queue.c src/core/surface/event_string.c src/core/surface/init.c src/core/surface/lame_client.c src/core/surface/metadata_array.c src/core/surface/server.c src/core/surface/server_chttp2.c src/core/surface/server_create.c src/core/surface/surface_trace.c src/core/transport/chttp2/alpn.c src/core/transport/chttp2/bin_encoder.c src/core/transport/chttp2/frame_data.c src/core/transport/chttp2/frame_goaway.c src/core/transport/chttp2/frame_ping.c src/core/transport/chttp2/frame_rst_stream.c src/core/transport/chttp2/frame_settings.c src/core/transport/chttp2/frame_window_update.c src/core/transport/chttp2/hpack_parser.c src/core/transport/chttp2/hpack_table.c src/core/transport/chttp2/huffsyms.c src/core/transport/chttp2/status_conversion.c src/core/transport/chttp2/stream_encoder.c src/core/transport/chttp2/stream_map.c src/core/transport/chttp2/timeout_encoding.c src/core/transport/chttp2/varint.c src/core/transport/chttp2_transport.c src/core/transport/metadata.c src/core/transport/stream_op.c src/core/transport/transport.c src/core/transport/transport_op_string.c src/core/census/context.c src/core/census/initialize.c include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_win32.h include/grpc/support/cancellable_platform.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/histogram.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_win32.h include/grpc/support/port_platform.h include/grpc/support/slice.h include/grpc/support/slice_buffer.h include/grpc/support/string_util.h include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h include/grpc/support/sync_win32.h include/grpc/support/thd.h include/grpc/support/time.h include/grpc/support/tls.h include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h include/grpc/support/useful.h src/core/support/env.h src/core/support/file.h src/core/support/murmur_hash.h src/core/support/string.h src/core/support/string_win32.h src/core/support/thd_internal.h src/core/support/alloc.c src/core/support/cancellable.c src/core/support/cmdline.c src/core/support/cpu_iphone.c src/core/support/cpu_linux.c src/core/support/cpu_posix.c src/core/support/cpu_windows.c src/core/support/env_linux.c src/core/support/env_posix.c src/core/support/env_win32.c src/core/support/file.c src/core/support/file_posix.c src/core/support/file_win32.c src/core/support/histogram.c src/core/support/host_port.c src/core/support/log.c src/core/support/log_android.c src/core/support/log_linux.c src/core/support/log_posix.c src/core/support/log_win32.c src/core/support/murmur_hash.c src/core/support/slice.c src/core/support/slice_buffer.c src/core/support/string.c src/core/support/string_posix.c src/core/support/string_win32.c src/core/support/subprocess_posix.c src/core/support/sync.c src/core/support/sync_posix.c src/core/support/sync_win32.c src/core/support/thd.c src/core/support/thd_posix.c src/core/support/thd_win32.c src/core/support/time.c src/core/support/time_posix.c src/core/support/time_win32.c src/core/support/tls_pthread.c # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 51529068cc5..99e2a83fbc7 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -176,9 +176,7 @@ - - @@ -320,12 +318,8 @@ - - - - diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index c7281c68c70..1565f1ff157 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -79,15 +79,9 @@ src\core\channel - - src\core\channel - src\core\channel - - src\core\channel - src\core\channel @@ -470,15 +464,9 @@ src\core\channel - - src\core\channel - src\core\channel - - src\core\channel - src\core\channel diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index 597dd2dc70b..a68efc62066 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -158,9 +158,7 @@ - - @@ -258,12 +256,8 @@ - - - - diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index 55f86a6a65f..38ba74281ab 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -13,15 +13,9 @@ src\core\channel - - src\core\channel - src\core\channel - - src\core\channel - src\core\channel @@ -353,15 +347,9 @@ src\core\channel - - src\core\channel - src\core\channel - - src\core\channel - src\core\channel From b7959a0b362daa951a245632ffa4617df4184a87 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 08:50:54 -0700 Subject: [PATCH 033/124] s/grpc_transport_op/grpc_transport_stream_op/g --- src/core/channel/census_filter.c | 14 ++++++++------ src/core/channel/channel_stack.c | 6 +++--- src/core/channel/channel_stack.h | 11 ++++++----- src/core/channel/client_channel.c | 16 ++++++++-------- src/core/channel/connected_channel.c | 4 ++-- src/core/channel/http_client_filter.c | 7 ++++--- src/core/channel/http_server_filter.c | 7 ++++--- src/core/channel/noop_filter.c | 7 ++++--- src/core/client_config/subchannel.h | 7 +++++-- src/core/security/client_auth_filter.c | 12 ++++++------ src/core/security/server_auth_filter.c | 4 ++-- src/core/surface/call.c | 14 +++++++------- src/core/surface/client.c | 4 ++-- src/core/surface/lame_client.c | 6 +++--- src/core/surface/server.c | 7 ++++--- src/core/transport/chttp2_transport.c | 13 ++++++++----- src/core/transport/transport.c | 13 +++++++------ src/core/transport/transport.h | 20 ++++++++++---------- src/core/transport/transport_impl.h | 5 +++-- src/core/transport/transport_op_string.c | 6 +++--- test/core/channel/channel_stack_test.c | 4 ++-- 21 files changed, 101 insertions(+), 86 deletions(-) diff --git a/src/core/channel/census_filter.c b/src/core/channel/census_filter.c index 7e393a01a6a..ea0bece587e 100644 --- a/src/core/channel/census_filter.c +++ b/src/core/channel/census_filter.c @@ -84,7 +84,8 @@ static void extract_and_annotate_method_tag(grpc_stream_op_buffer* sopb, } } -static void client_mutate_op(grpc_call_element* elem, grpc_transport_op* op) { +static void client_mutate_op(grpc_call_element* elem, + grpc_transport_stream_op* op) { call_data* calld = elem->call_data; channel_data* chand = elem->channel_data; if (op->send_ops) { @@ -93,7 +94,7 @@ static void client_mutate_op(grpc_call_element* elem, grpc_transport_op* op) { } static void client_start_transport_op(grpc_call_element* elem, - grpc_transport_op* op) { + grpc_transport_stream_op* op) { call_data* calld = elem->call_data; GPR_ASSERT((calld->op_id.upper != 0) || (calld->op_id.lower != 0)); client_mutate_op(elem, op); @@ -110,7 +111,8 @@ static void server_on_done_recv(void* ptr, int success) { calld->on_done_recv(calld->recv_user_data, success); } -static void server_mutate_op(grpc_call_element* elem, grpc_transport_op* op) { +static void server_mutate_op(grpc_call_element* elem, + grpc_transport_stream_op* op) { call_data* calld = elem->call_data; if (op->recv_ops) { /* substitute our callback for the op callback */ @@ -123,7 +125,7 @@ static void server_mutate_op(grpc_call_element* elem, grpc_transport_op* op) { } static void server_start_transport_op(grpc_call_element* elem, - grpc_transport_op* op) { + grpc_transport_stream_op* op) { call_data* calld = elem->call_data; GPR_ASSERT((calld->op_id.upper != 0) || (calld->op_id.lower != 0)); server_mutate_op(elem, op); @@ -145,7 +147,7 @@ static void channel_op(grpc_channel_element* elem, static void client_init_call_elem(grpc_call_element* elem, const void* server_transport_data, - grpc_transport_op* initial_op) { + grpc_transport_stream_op* initial_op) { call_data* d = elem->call_data; GPR_ASSERT(d != NULL); init_rpc_stats(&d->stats); @@ -163,7 +165,7 @@ static void client_destroy_call_elem(grpc_call_element* elem) { static void server_init_call_elem(grpc_call_element* elem, const void* server_transport_data, - grpc_transport_op* initial_op) { + grpc_transport_stream_op* initial_op) { call_data* d = elem->call_data; GPR_ASSERT(d != NULL); init_rpc_stats(&d->stats); diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c index 9eec8163f56..b575367b525 100644 --- a/src/core/channel/channel_stack.c +++ b/src/core/channel/channel_stack.c @@ -148,7 +148,7 @@ void grpc_channel_stack_destroy(grpc_channel_stack *stack) { void grpc_call_stack_init(grpc_channel_stack *channel_stack, const void *transport_server_data, - grpc_transport_op *initial_op, + grpc_transport_stream_op *initial_op, grpc_call_stack *call_stack) { grpc_channel_element *channel_elems = CHANNEL_ELEMS_FROM_STACK(channel_stack); size_t count = channel_stack->count; @@ -184,7 +184,7 @@ void grpc_call_stack_destroy(grpc_call_stack *stack) { } } -void grpc_call_next_op(grpc_call_element *elem, grpc_transport_op *op) { +void grpc_call_next_op(grpc_call_element *elem, grpc_transport_stream_op *op) { grpc_call_element *next_elem = elem + 1; next_elem->filter->start_transport_op(next_elem, op); } @@ -206,7 +206,7 @@ grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem) { } void grpc_call_element_send_cancel(grpc_call_element *cur_elem) { - grpc_transport_op op; + grpc_transport_stream_op op; memset(&op, 0, sizeof(op)); op.cancel_with_status = GRPC_STATUS_CANCELLED; grpc_call_next_op(cur_elem, &op); diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h index de0e4e45184..873a8ac4d38 100644 --- a/src/core/channel/channel_stack.h +++ b/src/core/channel/channel_stack.h @@ -103,7 +103,8 @@ typedef struct { typedef struct { /* Called to eg. send/receive data on a call. See grpc_call_next_op on how to call the next element in the stack */ - void (*start_transport_op)(grpc_call_element *elem, grpc_transport_op *op); + void (*start_transport_op)(grpc_call_element *elem, + grpc_transport_stream_op *op); /* Called to handle channel level operations - e.g. new calls, or transport closure. See grpc_channel_next_op on how to call the next element in the stack */ @@ -122,7 +123,7 @@ typedef struct { argument.*/ void (*init_call_elem)(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op); + grpc_transport_stream_op *initial_op); /* Destroy per call data. The filter does not need to do any chaining */ void (*destroy_call_elem)(grpc_call_element *elem); @@ -201,13 +202,13 @@ void grpc_channel_stack_destroy(grpc_channel_stack *stack); server. */ void grpc_call_stack_init(grpc_channel_stack *channel_stack, const void *transport_server_data, - grpc_transport_op *initial_op, + grpc_transport_stream_op *initial_op, grpc_call_stack *call_stack); /* Destroy a call stack */ void grpc_call_stack_destroy(grpc_call_stack *stack); /* Call the next operation in a call stack */ -void grpc_call_next_op(grpc_call_element *elem, grpc_transport_op *op); +void grpc_call_next_op(grpc_call_element *elem, grpc_transport_stream_op *op); /* Call the next operation (depending on call directionality) in a channel stack */ void grpc_channel_next_op(grpc_channel_element *elem, grpc_channel_op *op); @@ -219,7 +220,7 @@ grpc_channel_stack *grpc_channel_stack_from_top_element( grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem); void grpc_call_log_op(char *file, int line, gpr_log_severity severity, - grpc_call_element *elem, grpc_transport_op *op); + grpc_call_element *elem, grpc_transport_stream_op *op); void grpc_call_element_send_cancel(grpc_call_element *cur_elem); diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index ea79d539ec2..e171113dbc5 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -91,7 +91,7 @@ struct call_data { /* our child call stack */ grpc_subchannel_call *subchannel_call; } active; - grpc_transport_op waiting_op; + grpc_transport_stream_op waiting_op; struct { grpc_linked_mdelem status; grpc_linked_mdelem details; @@ -124,7 +124,7 @@ static int prepare_activate(grpc_call_element *elem, return 1; } -static void complete_activate(grpc_call_element *elem, grpc_transport_op *op) { +static void complete_activate(grpc_call_element *elem, grpc_transport_stream_op *op) { call_data *calld = elem->call_data; grpc_call_element *child_elem = grpc_child_call_get_top_element(calld->s.active.child_call); @@ -154,7 +154,7 @@ static void remove_waiting_child(channel_data *chand, call_data *calld) { #endif static void handle_op_after_cancellation(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; if (op->send_ops) { @@ -194,12 +194,12 @@ static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { } static void cc_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; grpc_subchannel_call *subchannel_call; grpc_lb_policy *lb_policy; - grpc_transport_op waiting_op; + grpc_transport_stream_op waiting_op; GPR_ASSERT(elem->filter == &grpc_client_channel_filter); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); @@ -457,7 +457,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { call_data *calld = elem->call_data; /* TODO(ctiller): is there something useful we can do here? */ @@ -555,7 +555,7 @@ grpc_transport_setup_result grpc_client_channel_transport_setup_complete( call_data **waiting_children; size_t waiting_child_count; size_t i; - grpc_transport_op *call_ops; + grpc_transport_stream_op *call_ops; /* build the child filter stack */ child_filters = gpr_malloc(sizeof(grpc_channel_filter *) * num_child_filters); @@ -597,7 +597,7 @@ grpc_transport_setup_result grpc_client_channel_transport_setup_complete( call_ops[i] = waiting_children[i]->s.waiting_op; if (!prepare_activate(waiting_children[i]->elem, chand->active_child)) { waiting_children[i] = NULL; - grpc_transport_op_finish_with_failure(&call_ops[i]); + grpc_transport_stream_op_finish_with_failure(&call_ops[i]); } } diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 14dda886983..6fad077c626 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -62,7 +62,7 @@ typedef struct connected_channel_call_data { void *unused; } call_data; /* Intercept a call operation and either push it directly up or translate it into transport stream operations */ static void con_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); @@ -96,7 +96,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; int r; diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index 9805f325a64..23f5a9bfe9f 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -87,7 +87,8 @@ static void hc_on_recv(void *user_data, int success) { calld->on_done_recv(calld->recv_user_data, success); } -static void hc_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { +static void hc_mutate_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; channel_data *channeld = elem->channel_data; @@ -124,7 +125,7 @@ static void hc_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { } static void hc_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { GRPC_CALL_LOG_OP(GPR_INFO, elem, op); hc_mutate_op(elem, op); grpc_call_next_op(elem, op); @@ -150,7 +151,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { call_data *calld = elem->call_data; calld->sent_initial_metadata = 0; calld->got_initial_metadata = 0; diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c index 11a53b1e70c..d653938ff29 100644 --- a/src/core/channel/http_server_filter.c +++ b/src/core/channel/http_server_filter.c @@ -177,7 +177,8 @@ static void hs_on_recv(void *user_data, int success) { calld->on_done_recv(calld->recv_user_data, success); } -static void hs_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { +static void hs_mutate_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; channel_data *channeld = elem->channel_data; @@ -207,7 +208,7 @@ static void hs_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { } static void hs_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { GRPC_CALL_LOG_OP(GPR_INFO, elem, op); hs_mutate_op(elem, op); grpc_call_next_op(elem, op); @@ -233,7 +234,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; /* initialize members */ diff --git a/src/core/channel/noop_filter.c b/src/core/channel/noop_filter.c index 1d2be716d77..d472b807440 100644 --- a/src/core/channel/noop_filter.c +++ b/src/core/channel/noop_filter.c @@ -45,7 +45,8 @@ typedef struct channel_data { /* used to silence 'variable not used' warnings */ static void ignore_unused(void *ignored) {} -static void noop_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { +static void noop_mutate_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; channel_data *channeld = elem->channel_data; @@ -62,7 +63,7 @@ static void noop_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { op contains type and call direction information, in addition to the data that is being sent or received. */ static void noop_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { noop_mutate_op(elem, op); /* pass control down the stack */ @@ -89,7 +90,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; channel_data *channeld = elem->channel_data; diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index c87d294d8c3..9128aaeda7e 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -77,9 +77,12 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, grpc_iomgr_closure *notify); /** construct a call */ -grpc_subchannel_call *grpc_subchannel_create_call(grpc_subchannel *subchannel, grpc_call_element *parent, grpc_transport_op *initial_op); +grpc_subchannel_call *grpc_subchannel_create_call( + grpc_subchannel *subchannel, grpc_call_element *parent, + grpc_transport_stream_op *initial_op); /** continue processing a transport op */ -void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, grpc_transport_op *op); +void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, + grpc_transport_stream_op *op); #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H */ diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index e9bd45db686..9ad4723ac52 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -58,7 +58,7 @@ typedef struct { so that work can progress when this call wants work to progress */ grpc_pollset *pollset; - grpc_transport_op op; + grpc_transport_stream_op op; size_t op_md_idx; int sent_initial_metadata; grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT]; @@ -77,7 +77,7 @@ typedef struct { static void bubble_up_error(grpc_call_element *elem, const char *error_msg) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; - grpc_transport_op_add_cancellation( + grpc_transport_stream_op_add_cancellation( &calld->op, GRPC_STATUS_UNAUTHENTICATED, grpc_mdstr_from_string(chand->md_ctx, error_msg)); grpc_call_next_op(elem, &calld->op); @@ -90,7 +90,7 @@ static void on_credentials_metadata(void *user_data, grpc_call_element *elem = (grpc_call_element *)user_data; call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; - grpc_transport_op *op = &calld->op; + grpc_transport_stream_op *op = &calld->op; grpc_metadata_batch *mdb; size_t i; if (status != GRPC_CREDENTIALS_OK) { @@ -131,7 +131,7 @@ static char *build_service_url(const char *url_scheme, call_data *calld) { } static void send_security_metadata(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; grpc_client_security_context *ctx = @@ -193,7 +193,7 @@ static void on_host_checked(void *user_data, grpc_security_status status) { op contains type and call direction information, in addition to the data that is being sent or received. */ static void auth_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; @@ -263,7 +263,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { call_data *calld = elem->call_data; calld->creds = NULL; calld->host = NULL; diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c index b19160b8ed5..2cb4bf612d6 100644 --- a/src/core/security/server_auth_filter.c +++ b/src/core/security/server_auth_filter.c @@ -51,7 +51,7 @@ typedef struct channel_data { op contains type and call direction information, in addition to the data that is being sent or received. */ static void auth_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { /* TODO(jboeuf): Get the metadata and get a new context from it. */ /* pass control down the stack */ @@ -68,7 +68,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; diff --git a/src/core/surface/call.c b/src/core/surface/call.c index dd8eaa943e5..d96b2d648ff 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -252,8 +252,8 @@ struct grpc_call { static void set_deadline_alarm(grpc_call *call, gpr_timespec deadline); static void call_on_done_recv(void *call, int success); static void call_on_done_send(void *call, int success); -static int fill_send_ops(grpc_call *call, grpc_transport_op *op); -static void execute_op(grpc_call *call, grpc_transport_op *op); +static int fill_send_ops(grpc_call *call, grpc_transport_stream_op *op); +static void execute_op(grpc_call *call, grpc_transport_stream_op *op); static void recv_metadata(grpc_call *call, grpc_metadata_batch *metadata); static void finish_read_ops(grpc_call *call); static grpc_call_error cancel_with_status(grpc_call *c, grpc_status_code status, @@ -268,8 +268,8 @@ grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq, size_t add_initial_metadata_count, gpr_timespec send_deadline) { size_t i; - grpc_transport_op initial_op; - grpc_transport_op *initial_op_ptr = NULL; + grpc_transport_stream_op initial_op; + grpc_transport_stream_op *initial_op_ptr = NULL; grpc_channel_stack *channel_stack = grpc_channel_get_channel_stack(channel); grpc_call *call = gpr_malloc(sizeof(grpc_call) + channel_stack->call_stack_size); @@ -454,7 +454,7 @@ static int need_more_data(grpc_call *call) { } static void unlock(grpc_call *call) { - grpc_transport_op op; + grpc_transport_stream_op op; completed_request completed_requests[GRPC_IOREQ_OP_COUNT]; int completing_requests = 0; int start_op = 0; @@ -868,7 +868,7 @@ static void copy_byte_buffer_to_stream_ops(grpc_byte_buffer *byte_buffer, } } -static int fill_send_ops(grpc_call *call, grpc_transport_op *op) { +static int fill_send_ops(grpc_call *call, grpc_transport_stream_op *op) { grpc_ioreq_data data; gpr_uint32 flags; grpc_metadata_batch mdb; @@ -1115,7 +1115,7 @@ static void finished_loose_op(void *call, int success_ignored) { GRPC_CALL_INTERNAL_UNREF(call, "loose-op", 0); } -static void execute_op(grpc_call *call, grpc_transport_op *op) { +static void execute_op(grpc_call *call, grpc_transport_stream_op *op) { grpc_call_element *elem; GPR_ASSERT(op->on_consumed == NULL); diff --git a/src/core/surface/client.c b/src/core/surface/client.c index 8ac4dd1e0e2..9c9cba57715 100644 --- a/src/core/surface/client.c +++ b/src/core/surface/client.c @@ -44,7 +44,7 @@ typedef struct { void *unused; } call_data; typedef struct { void *unused; } channel_data; static void client_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { GRPC_CALL_LOG_OP(GPR_INFO, elem, op); grpc_call_next_op(elem, op); } @@ -69,7 +69,7 @@ static void channel_op(grpc_channel_element *elem, static void init_call_elem(grpc_call_element *elem, const void *transport_server_data, - grpc_transport_op *initial_op) {} + grpc_transport_stream_op *initial_op) {} static void destroy_call_elem(grpc_call_element *elem) {} diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index b667128aef2..d3fe9fffb7d 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -50,7 +50,7 @@ typedef struct { typedef struct { grpc_mdctx *mdctx; } channel_data; static void lame_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; GRPC_CALL_LOG_OP(GPR_INFO, elem, op); @@ -98,9 +98,9 @@ static void channel_op(grpc_channel_element *elem, static void init_call_elem(grpc_call_element *elem, const void *transport_server_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { if (initial_op) { - grpc_transport_op_finish_with_failure(initial_op); + grpc_transport_stream_op_finish_with_failure(initial_op); } } diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 546b17c1ff2..445bd1a103f 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -526,7 +526,8 @@ static void server_on_recv(void *ptr, int success) { calld->on_done_recv(calld->recv_user_data, success); } -static void server_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { +static void server_mutate_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; if (op->recv_ops) { @@ -541,7 +542,7 @@ static void server_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { } static void server_start_transport_op(grpc_call_element *elem, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { GRPC_CALL_LOG_OP(GPR_INFO, elem, op); server_mutate_op(elem, op); grpc_call_next_op(elem, op); @@ -625,7 +626,7 @@ static void shutdown_channel(channel_data *chand, int send_goaway, static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; memset(calld, 0, sizeof(call_data)); diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 1cd1dc822d4..93d77159193 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -232,7 +232,7 @@ struct transport { gpr_uint8 writing; /** are we calling back (via cb) with a channel-level event */ gpr_uint8 calling_back_channel; - /** are we calling back any grpc_transport_op completion events */ + /** are we calling back any grpc_transport_stream_op completion events */ gpr_uint8 calling_back_ops; gpr_uint8 destroying; gpr_uint8 closed; @@ -399,7 +399,8 @@ static void maybe_finish_read(transport *t, stream *s); static void maybe_join_window_updates(transport *t, stream *s); static void finish_reads(transport *t); static void add_to_pollset_locked(transport *t, grpc_pollset *pollset); -static void perform_op_locked(transport *t, stream *s, grpc_transport_op *op); +static void perform_op_locked(transport *t, stream *s, + grpc_transport_stream_op *op); static void add_metadata_batch(transport *t, stream *s); static void flowctl_trace(transport *t, const char *flow, gpr_int32 window, @@ -644,7 +645,8 @@ static void goaway(grpc_transport *gt, grpc_status_code status, } static int init_stream(grpc_transport *gt, grpc_stream *gs, - const void *server_data, grpc_transport_op *initial_op) { + const void *server_data, + grpc_transport_stream_op *initial_op) { transport *t = (transport *)gt; stream *s = (stream *)gs; @@ -1127,7 +1129,8 @@ static void maybe_start_some_streams(transport *t) { } } -static void perform_op_locked(transport *t, stream *s, grpc_transport_op *op) { +static void perform_op_locked(transport *t, stream *s, + grpc_transport_stream_op *op) { if (op->cancel_with_status != GRPC_STATUS_OK) { cancel_stream( t, s, op->cancel_with_status, @@ -1186,7 +1189,7 @@ static void perform_op_locked(transport *t, stream *s, grpc_transport_op *op) { } static void perform_op(grpc_transport *gt, grpc_stream *gs, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { transport *t = (transport *)gt; stream *s = (stream *)gs; diff --git a/src/core/transport/transport.c b/src/core/transport/transport.c index a9948cd4b2a..400c2023a96 100644 --- a/src/core/transport/transport.c +++ b/src/core/transport/transport.c @@ -53,13 +53,13 @@ void grpc_transport_destroy(grpc_transport *transport) { int grpc_transport_init_stream(grpc_transport *transport, grpc_stream *stream, const void *server_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { return transport->vtable->init_stream(transport, stream, server_data, initial_op); } void grpc_transport_perform_op(grpc_transport *transport, grpc_stream *stream, - grpc_transport_op *op) { + grpc_transport_stream_op *op) { transport->vtable->perform_op(transport, stream, op); } @@ -96,7 +96,8 @@ void grpc_transport_setup_del_interested_party(grpc_transport_setup *setup, setup->vtable->del_interested_party(setup, pollset); } -void grpc_transport_op_finish_with_failure(grpc_transport_op *op) { +void grpc_transport_stream_op_finish_with_failure( + grpc_transport_stream_op *op) { if (op->send_ops) { op->on_done_send(op->send_user_data, 0); } @@ -108,9 +109,9 @@ void grpc_transport_op_finish_with_failure(grpc_transport_op *op) { } } -void grpc_transport_op_add_cancellation(grpc_transport_op *op, - grpc_status_code status, - grpc_mdstr *message) { +void grpc_transport_stream_op_add_cancellation(grpc_transport_stream_op *op, + grpc_status_code status, + grpc_mdstr *message) { if (op->cancel_with_status == GRPC_STATUS_OK) { op->cancel_with_status = status; op->cancel_message = message; diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h index 7f60fdc0374..72bc492d800 100644 --- a/src/core/transport/transport.h +++ b/src/core/transport/transport.h @@ -63,7 +63,7 @@ typedef enum grpc_stream_state { } grpc_stream_state; /* Transport op: a set of operations to perform on a transport */ -typedef struct grpc_transport_op { +typedef struct grpc_transport_stream_op { void (*on_consumed)(void *user_data, int success); void *on_consumed_user_data; @@ -84,7 +84,7 @@ typedef struct grpc_transport_op { /* Indexes correspond to grpc_context_index enum values */ grpc_call_context_element *context; -} grpc_transport_op; +} grpc_transport_stream_op; /* Callbacks made from the transport to the upper layers of grpc. */ struct grpc_transport_callbacks { @@ -126,7 +126,7 @@ size_t grpc_transport_stream_size(grpc_transport *transport); supplied from the accept_stream callback function */ int grpc_transport_init_stream(grpc_transport *transport, grpc_stream *stream, const void *server_data, - grpc_transport_op *initial_op); + grpc_transport_stream_op *initial_op); /* Destroy transport data for a stream. @@ -141,17 +141,17 @@ int grpc_transport_init_stream(grpc_transport *transport, grpc_stream *stream, void grpc_transport_destroy_stream(grpc_transport *transport, grpc_stream *stream); -void grpc_transport_op_finish_with_failure(grpc_transport_op *op); +void grpc_transport_stream_op_finish_with_failure(grpc_transport_stream_op *op); -void grpc_transport_op_add_cancellation(grpc_transport_op *op, - grpc_status_code status, - grpc_mdstr *message); +void grpc_transport_stream_op_add_cancellation(grpc_transport_stream_op *op, + grpc_status_code status, + grpc_mdstr *message); /* TODO(ctiller): remove this */ void grpc_transport_add_to_pollset(grpc_transport *transport, grpc_pollset *pollset); -char *grpc_transport_op_string(grpc_transport_op *op); +char *grpc_transport_stream_op_string(grpc_transport_stream_op *op); /* Send a batch of operations on a transport @@ -161,9 +161,9 @@ char *grpc_transport_op_string(grpc_transport_op *op); transport - the transport on which to initiate the stream stream - the stream on which to send the operations. This must be non-NULL and previously initialized by the same transport. - op - a grpc_transport_op specifying the op to perform */ + op - a grpc_transport_stream_op specifying the op to perform */ void grpc_transport_perform_op(grpc_transport *transport, grpc_stream *stream, - grpc_transport_op *op); + grpc_transport_stream_op *op); /* Send a ping on a transport diff --git a/src/core/transport/transport_impl.h b/src/core/transport/transport_impl.h index 479e15338f8..2f940dde1c9 100644 --- a/src/core/transport/transport_impl.h +++ b/src/core/transport/transport_impl.h @@ -43,11 +43,12 @@ typedef struct grpc_transport_vtable { /* implementation of grpc_transport_init_stream */ int (*init_stream)(grpc_transport *self, grpc_stream *stream, - const void *server_data, grpc_transport_op *initial_op); + const void *server_data, + grpc_transport_stream_op *initial_op); /* implementation of grpc_transport_send_batch */ void (*perform_op)(grpc_transport *self, grpc_stream *stream, - grpc_transport_op *op); + grpc_transport_stream_op *op); /* implementation of grpc_transport_add_to_pollset */ void (*add_to_pollset)(grpc_transport *self, grpc_pollset *pollset); diff --git a/src/core/transport/transport_op_string.c b/src/core/transport/transport_op_string.c index 5c4edb006aa..43e14a77925 100644 --- a/src/core/transport/transport_op_string.c +++ b/src/core/transport/transport_op_string.c @@ -107,7 +107,7 @@ char *grpc_sopb_string(grpc_stream_op_buffer *sopb) { return out; } -char *grpc_transport_op_string(grpc_transport_op *op) { +char *grpc_transport_stream_op_string(grpc_transport_stream_op *op) { char *tmp; char *out; int first = 1; @@ -158,8 +158,8 @@ char *grpc_transport_op_string(grpc_transport_op *op) { } void grpc_call_log_op(char *file, int line, gpr_log_severity severity, - grpc_call_element *elem, grpc_transport_op *op) { - char *str = grpc_transport_op_string(op); + grpc_call_element *elem, grpc_transport_stream_op *op) { + char *str = grpc_transport_stream_op_string(op); gpr_log(file, line, severity, "OP[%s:%p]: %s", elem->filter->name, elem, str); gpr_free(str); } diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index fe92f2f0233..78779484b2d 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -54,7 +54,7 @@ static void channel_init_func(grpc_channel_element *elem, static void call_init_func(grpc_call_element *elem, const void *server_transport_data, - grpc_transport_op *initial_op) { + grpc_transport_stream_op *initial_op) { ++*(int *)(elem->channel_data); *(int *)(elem->call_data) = 0; } @@ -65,7 +65,7 @@ static void call_destroy_func(grpc_call_element *elem) { ++*(int *)(elem->channel_data); } -static void call_func(grpc_call_element *elem, grpc_transport_op *op) { +static void call_func(grpc_call_element *elem, grpc_transport_stream_op *op) { ++*(int *)(elem->call_data); } From 3f475422ecb8cd5c648ce86f126122ba6dee1c9c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 10:43:05 -0700 Subject: [PATCH 034/124] chop chop chop --- include/grpc/grpc.h | 14 +++ src/core/channel/channel_stack.c | 8 +- src/core/channel/channel_stack.h | 46 +------- src/core/channel/client_channel.c | 147 +++++++++++++++++--------- src/core/client_config/subchannel.h | 16 --- src/core/transport/chttp2_transport.c | 35 ------ src/core/transport/transport.c | 9 +- src/core/transport/transport.h | 58 +++++----- src/core/transport/transport_impl.h | 19 +--- 9 files changed, 154 insertions(+), 198 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 8b4676562bb..bb6753a9bb5 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -118,6 +118,20 @@ typedef struct { #define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ "grpc.http2.initial_sequence_number" +/** Connectivity state of a channel. */ +typedef enum { + /** channel is connecting */ + GRPC_CHANNEL_CONNECTING, + /** channel is ready for work */ + GRPC_CHANNEL_READY, + /** channel has seen a failure but expects to recover */ + GRPC_CHANNEL_TRANSIENT_FAILURE, + /** channel is idle */ + GRPC_CHANNEL_IDLE, + /** channel has seen a failure that it cannot recover from */ + GRPC_CHANNEL_FATAL_FAILURE +} grpc_connectivity_state; + /* Result of a grpc call. If the caller satisfies the prerequisites of a particular operation, the grpc_call_error returned will be GRPC_CALL_OK. Receiving any other value listed here is an indication of a bug in the diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c index b575367b525..ff1077ce4cb 100644 --- a/src/core/channel/channel_stack.c +++ b/src/core/channel/channel_stack.c @@ -186,12 +186,12 @@ void grpc_call_stack_destroy(grpc_call_stack *stack) { void grpc_call_next_op(grpc_call_element *elem, grpc_transport_stream_op *op) { grpc_call_element *next_elem = elem + 1; - next_elem->filter->start_transport_op(next_elem, op); + next_elem->filter->start_transport_stream_op(next_elem, op); } -void grpc_channel_next_op(grpc_channel_element *elem, grpc_channel_op *op) { - grpc_channel_element *next_elem = elem + op->dir; - next_elem->filter->channel_op(next_elem, elem, op); +void grpc_channel_next_op(grpc_channel_element *elem, grpc_transport_op *op) { + grpc_channel_element *next_elem = elem + 1; + next_elem->filter->start_transport_op(next_elem, op); } grpc_channel_stack *grpc_channel_stack_from_top_element( diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h index 873a8ac4d38..5ac2372f3a6 100644 --- a/src/core/channel/channel_stack.h +++ b/src/core/channel/channel_stack.h @@ -51,45 +51,6 @@ typedef struct grpc_channel_element grpc_channel_element; typedef struct grpc_call_element grpc_call_element; -/* The direction of the call. - The values of the enums (1, -1) matter here - they are used to increment - or decrement a pointer to find the next element to call */ -typedef enum { GRPC_CALL_DOWN = 1, GRPC_CALL_UP = -1 } grpc_call_dir; - -typedef enum { - /* send a goaway message to remote channels indicating that we are going - to disconnect in the future */ - GRPC_CHANNEL_GOAWAY, - /* disconnect any underlying transports */ - GRPC_CHANNEL_DISCONNECT, - /* transport received a new call */ - GRPC_ACCEPT_CALL, - /* an underlying transport was closed */ - GRPC_TRANSPORT_CLOSED, - /* an underlying transport is about to be closed */ - GRPC_TRANSPORT_GOAWAY -} grpc_channel_op_type; - -/* A single filterable operation to be performed on a channel */ -typedef struct { - /* The type of operation we're performing */ - grpc_channel_op_type type; - /* The directionality of this call - is it bubbling up the stack, or down? */ - grpc_call_dir dir; - - /* Argument data, matching up with grpc_channel_op_type names */ - union { - struct { - grpc_transport *transport; - const void *transport_server_data; - } accept_call; - struct { - grpc_status_code status; - gpr_slice message; - } goaway; - } data; -} grpc_channel_op; - /* Channel filters specify: 1. the amount of memory needed in the channel & call (via the sizeof_XXX members) @@ -103,13 +64,12 @@ typedef struct { typedef struct { /* Called to eg. send/receive data on a call. See grpc_call_next_op on how to call the next element in the stack */ - void (*start_transport_op)(grpc_call_element *elem, + void (*start_transport_stream_op)(grpc_call_element *elem, grpc_transport_stream_op *op); /* Called to handle channel level operations - e.g. new calls, or transport closure. See grpc_channel_next_op on how to call the next element in the stack */ - void (*channel_op)(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op); + void (*start_transport_op)(grpc_channel_element *elem, grpc_transport_op *op); /* sizeof(per call data) */ size_t sizeof_call_data; @@ -211,7 +171,7 @@ void grpc_call_stack_destroy(grpc_call_stack *stack); void grpc_call_next_op(grpc_call_element *elem, grpc_transport_stream_op *op); /* Call the next operation (depending on call directionality) in a channel stack */ -void grpc_channel_next_op(grpc_channel_element *elem, grpc_channel_op *op); +void grpc_channel_next_op(grpc_channel_element *elem, grpc_transport_op *op); /* Given the top element of a channel stack, get the channel stack itself */ grpc_channel_stack *grpc_channel_stack_from_top_element( diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 4ae951074dc..9630f6898d8 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -54,26 +54,27 @@ typedef struct { grpc_mdctx *mdctx; /** resolver for this channel */ grpc_resolver *resolver; - /** channel arguments for this channel - TODO(ctiller): still needed? */ - grpc_channel_args *args; - /** mutex protecting waiting list */ - gpr_mu mu_waiting; /** mutex protecting client configuration, resolution state */ gpr_mu mu_config; - /** currently active load balancer - guarded by mu_config */ grpc_lb_policy *lb_policy; - /** incoming configuration - set by resolver.next guarded by mu_config */ grpc_client_config *incoming_configuration; + /** a list of closures that are all waiting for config to come in */ + grpc_iomgr_closure *waiting_for_config_closures; + /** resolver callback */ + grpc_iomgr_closure on_config_changed; + /** connectivity state being tracked */ + grpc_iomgr_closure *on_connectivity_state_change; + grpc_connectivity_state *connectivity_state; } channel_data; typedef enum { CALL_CREATED, - CALL_WAITING, + CALL_WAITING_FOR_CONFIG, + CALL_WAITING_FOR_PICK, CALL_ACTIVE, CALL_CANCELLED } call_state; @@ -193,13 +194,12 @@ static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { abort(); } -static void cc_start_transport_op(grpc_call_element *elem, +static void cc_start_transport_stream_op(grpc_call_element *elem, grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; grpc_subchannel_call *subchannel_call; grpc_lb_policy *lb_policy; - grpc_transport_stream_op waiting_op; GPR_ASSERT(elem->filter == &grpc_client_channel_filter); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); @@ -207,10 +207,8 @@ static void cc_start_transport_op(grpc_call_element *elem, switch (calld->state) { case CALL_ACTIVE: subchannel_call = calld->s.active.subchannel_call; - grpc_subchannel_call_ref(subchannel_call); gpr_mu_unlock(&calld->mu_state); grpc_subchannel_call_process_op(subchannel_call, op); - grpc_subchannel_call_unref(subchannel_call); break; case CALL_CANCELLED: gpr_mu_unlock(&calld->mu_state); @@ -222,7 +220,6 @@ static void cc_start_transport_op(grpc_call_element *elem, gpr_mu_unlock(&calld->mu_state); handle_op_after_cancellation(elem, op); } else { - calld->state = CALL_WAITING; calld->s.waiting_op = *op; gpr_mu_lock(&chand->mu_config); @@ -230,45 +227,44 @@ static void cc_start_transport_op(grpc_call_element *elem, if (lb_policy) { grpc_lb_policy_ref(lb_policy); gpr_mu_unlock(&chand->mu_config); + calld->state = CALL_WAITING_FOR_PICK; gpr_mu_unlock(&calld->mu_state); pick_target(lb_policy, calld); grpc_lb_policy_unref(lb_policy); } else { + calld->state = CALL_WAITING_FOR_CONFIG; add_to_lb_policy_wait_queue_locked_state_config(chand, calld); gpr_mu_unlock(&chand->mu_config); gpr_mu_unlock(&calld->mu_state); } } break; - case CALL_WAITING: + case CALL_WAITING_FOR_CONFIG: + case CALL_WAITING_FOR_PICK: if (op->cancel_with_status != GRPC_STATUS_OK) { - waiting_op = calld->s.waiting_op; calld->state = CALL_CANCELLED; gpr_mu_unlock(&calld->mu_state); - handle_op_after_cancellation(elem, &waiting_op); handle_op_after_cancellation(elem, op); } else { GPR_ASSERT((calld->s.waiting_op.send_ops == NULL) != (op->send_ops == NULL)); GPR_ASSERT((calld->s.waiting_op.recv_ops == NULL) != (op->recv_ops == NULL)); - if (op->send_ops) { + if (op->send_ops != NULL) { calld->s.waiting_op.send_ops = op->send_ops; calld->s.waiting_op.is_last_send = op->is_last_send; calld->s.waiting_op.on_done_send = op->on_done_send; - calld->s.waiting_op.send_user_data = op->send_user_data; } - if (op->recv_ops) { + if (op->recv_ops != NULL) { calld->s.waiting_op.recv_ops = op->recv_ops; calld->s.waiting_op.recv_state = op->recv_state; calld->s.waiting_op.on_done_recv = op->on_done_recv; - calld->s.waiting_op.recv_user_data = op->recv_user_data; } gpr_mu_unlock(&calld->mu_state); - if (op->on_consumed) { - op->on_consumed(op->on_consumed_user_data, 0); + if (op->on_consumed != NULL) { + op->on_consumed->cb(op->on_consumed->cb_arg, 0); } } break; @@ -372,6 +368,55 @@ static void cc_start_transport_op(grpc_call_element *elem, #endif } +static void update_state_locked(channel_data *chand) { + +} + +static void cc_on_config_changed(void *arg, int iomgr_success) { + channel_data *chand = arg; + grpc_lb_policy *lb_policy = NULL; + grpc_lb_policy *old_lb_policy; + grpc_resolver *old_resolver; + grpc_iomgr_closure *wakeup_closures = NULL; + + if (chand->incoming_configuration) { + lb_policy = grpc_client_config_get_lb_policy(chand->incoming_configuration); + grpc_lb_policy_ref(lb_policy); + } + + grpc_client_config_unref(chand->incoming_configuration); + chand->incoming_configuration = NULL; + + gpr_mu_lock(&chand->mu_config); + old_lb_policy = chand->lb_policy; + chand->lb_policy = lb_policy; + if (lb_policy != NULL) { + wakeup_closures = chand->waiting_for_config_closures; + chand->waiting_for_config_closures = NULL; + } + gpr_mu_unlock(&chand->mu_config); + + while (wakeup_closures) { + grpc_iomgr_closure *next = wakeup_closures->next; + grpc_iomgr_add_callback(wakeup_closures); + wakeup_closures = next; + } + + grpc_lb_policy_unref(old_lb_policy); + + if (iomgr_success) { + grpc_resolver_next(chand->resolver, &chand->incoming_configuration, &chand->on_config_changed); + } else { + gpr_mu_lock(&chand->mu_config); + old_resolver = chand->resolver; + chand->resolver = NULL; + update_state_locked(chand); + gpr_mu_unlock(&chand->mu_config); + grpc_resolver_unref(old_resolver); + } +} + +#if 0 static void channel_op(grpc_channel_element *elem, grpc_channel_element *from_elem, grpc_channel_op *op) { channel_data *chand = elem->channel_data; @@ -451,6 +496,9 @@ static void channel_op(grpc_channel_element *elem, break; } } +#endif + +static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op *op) {} /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, @@ -471,26 +519,28 @@ static void init_call_elem(grpc_call_element *elem, /* Destructor for call_data */ static void destroy_call_elem(grpc_call_element *elem) { call_data *calld = elem->call_data; - channel_data *chand = elem->channel_data; + grpc_subchannel_call *subchannel_call; /* if the call got activated, we need to destroy the child stack also, and remove it from the in-flight requests tracked by the child_entry we picked */ - gpr_mu_lock(&chand->mu); + gpr_mu_lock(&calld->mu_state); switch (calld->state) { case CALL_ACTIVE: - gpr_mu_unlock(&chand->mu); - grpc_child_call_destroy(calld->s.active.child_call); + subchannel_call = calld->s.active.subchannel_call; + gpr_mu_unlock(&calld->mu_state); + grpc_subchannel_call_unref(subchannel_call); break; - case CALL_WAITING: - remove_waiting_child(chand, calld); - gpr_mu_unlock(&chand->mu); + case CALL_CREATED: + case CALL_CANCELLED: + gpr_mu_unlock(&calld->mu_state); break; - default: - gpr_mu_unlock(&chand->mu); + case CALL_WAITING_FOR_PICK: + case CALL_WAITING_FOR_CONFIG: + gpr_log(GPR_ERROR, "should never reach here"); + abort(); break; } - GPR_ASSERT(calld->state != CALL_WAITING); } /* Constructor for channel_data */ @@ -504,41 +554,32 @@ static void init_channel_elem(grpc_channel_element *elem, GPR_ASSERT(is_last); GPR_ASSERT(elem->filter == &grpc_client_channel_filter); - gpr_mu_init(&chand->mu); - chand->active_child = NULL; - chand->waiting_children = NULL; - chand->waiting_child_count = 0; - chand->waiting_child_capacity = 0; - chand->transport_setup = NULL; - chand->transport_setup_initiated = 0; - chand->args = grpc_channel_args_copy(args); + gpr_mu_init(&chand->mu_config); + chand->resolver = NULL; chand->mdctx = metadata_context; + grpc_iomgr_closure_init(&chand->on_config_changed, cc_on_config_changed, chand); } /* Destructor for channel_data */ static void destroy_channel_elem(grpc_channel_element *elem) { channel_data *chand = elem->channel_data; - grpc_transport_setup_cancel(chand->transport_setup); - - if (chand->active_child) { - grpc_child_channel_destroy(chand->active_child, 1); - chand->active_child = NULL; + if (chand->resolver) { + grpc_resolver_unref(chand->resolver); } - - grpc_channel_args_destroy(chand->args); - - gpr_mu_destroy(&chand->mu); - GPR_ASSERT(chand->waiting_child_count == 0); - gpr_free(chand->waiting_children); + if (chand->lb_policy) { + grpc_lb_policy_unref(chand->lb_policy); + } + gpr_mu_destroy(&chand->mu_config); } const grpc_channel_filter grpc_client_channel_filter = { - cc_start_transport_op, channel_op, sizeof(call_data), + cc_start_transport_stream_op, cc_start_transport_op, sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem, "client-channel", }; +#if 0 grpc_transport_setup_result grpc_client_channel_transport_setup_complete( grpc_channel_stack *channel_stack, grpc_transport *transport, grpc_channel_filter const **channel_filters, size_t num_channel_filters, @@ -620,6 +661,7 @@ grpc_transport_setup_result grpc_client_channel_transport_setup_complete( return result; } +#endif void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, grpc_resolver *resolver) { @@ -628,5 +670,6 @@ void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, channel_data *chand = elem->channel_data; GPR_ASSERT(!chand->resolver); chand->resolver = resolver; + grpc_resolver_ref(resolver); grpc_resolver_next(resolver, &chand->incoming_configuration, &chand->on_config_changed); } diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 9128aaeda7e..0c6c9b3e64d 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -44,22 +44,6 @@ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; -/** Connectivity state of a channel. - TODO(ctiller): move to grpc.h when we implement the public - version of the connectivity apis */ -typedef enum { - /** channel is connecting */ - GRPC_CHANNEL_CONNECTING, - /** channel is ready for work */ - GRPC_CHANNEL_READY, - /** channel has seen a failure but expects to recover */ - GRPC_CHANNEL_TRANSIENT_FAILURE, - /** channel is idle */ - GRPC_CHANNEL_IDLE, - /** channel has seen a failure that it cannot recover from */ - GRPC_CHANNEL_FATAL_FAILURE -} grpc_connectivity_state; - void grpc_subchannel_ref(grpc_subchannel *channel); void grpc_subchannel_unref(grpc_subchannel *channel); diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 9943dbdbace..685098bcba9 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -114,26 +114,9 @@ static void cancel_from_api(grpc_chttp2_transport_global *transport_global, static void add_to_pollset_locked(grpc_chttp2_transport *t, grpc_pollset *pollset); -<<<<<<< HEAD -static void schedule_cb(transport *t, op_closure closure, int success); -static void maybe_finish_read(transport *t, stream *s); -static void maybe_join_window_updates(transport *t, stream *s); -static void finish_reads(transport *t); -static void add_to_pollset_locked(transport *t, grpc_pollset *pollset); -static void perform_op_locked(transport *t, stream *s, - grpc_transport_stream_op *op); -static void add_metadata_batch(transport *t, stream *s); - -static void flowctl_trace(transport *t, const char *flow, gpr_int32 window, - gpr_uint32 id, gpr_int32 delta) { - gpr_log(GPR_DEBUG, "HTTP:FLOW:%p:%d:%s: %d + %d = %d", t, id, flow, window, - delta, window + delta); -} -======= /** Start new streams that have been created if we can */ static void maybe_start_some_streams( grpc_chttp2_transport_global *transport_global); ->>>>>>> 48f0a13f3872876787f4d7588b396db914319b1b /* * CONSTRUCTION/DESTRUCTION/REFCOUNTING @@ -385,16 +368,9 @@ static void goaway(grpc_transport *gt, grpc_status_code status, } static int init_stream(grpc_transport *gt, grpc_stream *gs, -<<<<<<< HEAD - const void *server_data, - grpc_transport_stream_op *initial_op) { - transport *t = (transport *)gt; - stream *s = (stream *)gs; -======= const void *server_data, grpc_transport_stream_op *initial_op) { grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs; ->>>>>>> 48f0a13f3872876787f4d7588b396db914319b1b memset(s, 0, sizeof(*s)); @@ -635,14 +611,9 @@ static void maybe_start_some_streams( } } -<<<<<<< HEAD -static void perform_op_locked(transport *t, stream *s, - grpc_transport_stream_op *op) { -======= static void perform_op_locked(grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global, grpc_transport_stream_op *op) { ->>>>>>> 48f0a13f3872876787f4d7588b396db914319b1b if (op->cancel_with_status != GRPC_STATUS_OK) { cancel_from_api(transport_global, stream_global, op->cancel_with_status); } @@ -699,15 +670,9 @@ static void perform_op_locked(grpc_chttp2_transport_global *transport_global, } static void perform_op(grpc_transport *gt, grpc_stream *gs, -<<<<<<< HEAD - grpc_transport_stream_op *op) { - transport *t = (transport *)gt; - stream *s = (stream *)gs; -======= grpc_transport_stream_op *op) { grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs; ->>>>>>> 48f0a13f3872876787f4d7588b396db914319b1b lock(t); perform_op_locked(&t->global, &s->global, op); diff --git a/src/core/transport/transport.c b/src/core/transport/transport.c index a73c32da1a7..40faa272111 100644 --- a/src/core/transport/transport.c +++ b/src/core/transport/transport.c @@ -58,9 +58,14 @@ int grpc_transport_init_stream(grpc_transport *transport, grpc_stream *stream, initial_op); } -void grpc_transport_perform_op(grpc_transport *transport, grpc_stream *stream, +void grpc_transport_perform_stream_op(grpc_transport *transport, grpc_stream *stream, grpc_transport_stream_op *op) { - transport->vtable->perform_op(transport, stream, op); + transport->vtable->perform_stream_op(transport, stream, op); +} + +void grpc_transport_perform_op(grpc_transport *transport, + grpc_transport_op *op) { + transport->vtable->perform_op(transport, op); } void grpc_transport_add_to_pollset(grpc_transport *transport, diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h index fbfed466266..7f6a37d0481 100644 --- a/src/core/transport/transport.h +++ b/src/core/transport/transport.h @@ -43,7 +43,6 @@ /* forward declarations */ typedef struct grpc_transport grpc_transport; -typedef struct grpc_transport_callbacks grpc_transport_callbacks; /* grpc_stream doesn't actually exist. It's used as a typesafe opaque pointer for whatever data the transport wants to track @@ -62,7 +61,8 @@ typedef enum grpc_stream_state { GRPC_STREAM_CLOSED } grpc_stream_state; -/* Transport op: a set of operations to perform on a transport */ +/* Transport stream op: a set of operations to perform on a transport + against a single stream */ typedef struct grpc_transport_stream_op { grpc_iomgr_closure *on_consumed; @@ -83,30 +83,27 @@ typedef struct grpc_transport_stream_op { grpc_call_context_element *context; } grpc_transport_stream_op; -/* Callbacks made from the transport to the upper layers of grpc. */ -struct grpc_transport_callbacks { - /* Initialize a new stream on behalf of the transport. - Must result in a call to - grpc_transport_init_stream(transport, ..., request) in the same call - stack. - Must not result in any other calls to the transport. - - Arguments: - user_data - the transport user data set at transport creation time - transport - the grpc_transport instance making this call - request - request parameters for this stream (owned by the caller) - server_data - opaque transport dependent argument that should be passed - to grpc_transport_init_stream - */ - void (*accept_stream)(void *user_data, grpc_transport *transport, - const void *server_data); - - void (*goaway)(void *user_data, grpc_transport *transport, - grpc_status_code status, gpr_slice debug); - - /* The transport has been closed */ - void (*closed)(void *user_data, grpc_transport *transport); -}; +/** Transport op: a set of operations to perform on a transport as a whole */ +typedef struct grpc_transport_op { + /** connectivity monitoring */ + grpc_iomgr_closure *on_connectivity_state_change; + grpc_connectivity_state *connectivity_state; + /** should the transport be disconnected */ + int disconnect; + /** should we send a goaway? */ + int send_goaway; + /** what should the goaway contain? */ + grpc_status_code goaway_status; + gpr_slice *goaway_message; + /** set the callback for accepting new streams; + this is a permanent callback, unlike the other one-shot closures */ + void (*set_accept_stream)(void *user_data, grpc_transport *transport, const void *server_data); + void *set_accept_stream_user_data; + /** add this transport to a pollset */ + grpc_pollset *bind_pollset; + /** send a ping, call this back if not NULL */ + grpc_iomgr_closure *send_ping; +} grpc_transport_op; /* Returns the amount of memory required to store a grpc_stream for this transport */ @@ -144,10 +141,6 @@ void grpc_transport_stream_op_add_cancellation(grpc_transport_stream_op *op, grpc_status_code status, grpc_mdstr *message); -/* TODO(ctiller): remove this */ -void grpc_transport_add_to_pollset(grpc_transport *transport, - grpc_pollset *pollset); - char *grpc_transport_stream_op_string(grpc_transport_stream_op *op); /* Send a batch of operations on a transport @@ -159,9 +152,11 @@ char *grpc_transport_stream_op_string(grpc_transport_stream_op *op); stream - the stream on which to send the operations. This must be non-NULL and previously initialized by the same transport. op - a grpc_transport_stream_op specifying the op to perform */ -void grpc_transport_perform_op(grpc_transport *transport, grpc_stream *stream, +void grpc_transport_perform_stream_op(grpc_transport *transport, grpc_stream *stream, grpc_transport_stream_op *op); +void grpc_transport_perform_op(grpc_transport *transport, grpc_transport_op *op); + /* Send a ping on a transport Calls cb with user data when a response is received. */ @@ -180,7 +175,6 @@ void grpc_transport_destroy(grpc_transport *transport); /* Return type for grpc_transport_setup_callback */ typedef struct grpc_transport_setup_result { void *user_data; - const grpc_transport_callbacks *callbacks; } grpc_transport_setup_result; /* Given a transport, return callbacks for that transport. Used to finalize diff --git a/src/core/transport/transport_impl.h b/src/core/transport/transport_impl.h index 442b64ca59f..b65b1d56078 100644 --- a/src/core/transport/transport_impl.h +++ b/src/core/transport/transport_impl.h @@ -46,26 +46,17 @@ typedef struct grpc_transport_vtable { const void *server_data, grpc_transport_stream_op *initial_op); - /* implementation of grpc_transport_send_batch */ - void (*perform_op)(grpc_transport *self, grpc_stream *stream, + /* implementation of grpc_transport_perform_stream_op */ + void (*perform_stream_op)(grpc_transport *self, grpc_stream *stream, grpc_transport_stream_op *op); - /* implementation of grpc_transport_add_to_pollset */ - void (*add_to_pollset)(grpc_transport *self, grpc_pollset *pollset); + /* implementation of grpc_transport_perform_op */ + void (*perform_op)(grpc_transport *self, grpc_stream *stream, + grpc_transport_stream_op *op); /* implementation of grpc_transport_destroy_stream */ void (*destroy_stream)(grpc_transport *self, grpc_stream *stream); - /* implementation of grpc_transport_goaway */ - void (*goaway)(grpc_transport *self, grpc_status_code status, - gpr_slice debug_data); - - /* implementation of grpc_transport_close */ - void (*close)(grpc_transport *self); - - /* implementation of grpc_transport_ping */ - void (*ping)(grpc_transport *self, grpc_iomgr_closure *cb); - /* implementation of grpc_transport_destroy */ void (*destroy)(grpc_transport *self); } grpc_transport_vtable; From e039f0338333e1a2f368ec20740662fb2eac2875 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 12:54:23 -0700 Subject: [PATCH 035/124] Plumbing transport_op changes through --- BUILD | 4 - Makefile | 2 - build.json | 2 - gRPC.podspec | 3 - src/core/channel/connected_channel.c | 94 +++------------- src/core/channel/http_client_filter.c | 23 +--- src/core/channel/http_server_filter.c | 26 +---- src/core/channel/noop_filter.c | 34 ++---- src/core/surface/call.c | 2 +- src/core/surface/channel.c | 24 ++--- src/core/surface/channel_create.c | 6 +- src/core/surface/client.c | 89 ---------------- src/core/surface/client.h | 41 ------- src/core/surface/lame_client.c | 43 ++++---- src/core/surface/server.c | 100 +++++++++++++----- src/core/transport/chttp2_transport.c | 4 - src/core/transport/transport.c | 18 ---- src/core/transport/transport.h | 2 + src/core/transport/transport_impl.h | 2 +- test/core/end2end/fixtures/chttp2_fullstack.c | 1 - tools/doxygen/Doxyfile.core.internal | 2 - vsprojects/grpc/grpc.vcxproj | 3 - vsprojects/grpc/grpc.vcxproj.filters | 6 -- .../grpc_unsecure/grpc_unsecure.vcxproj | 3 - .../grpc_unsecure.vcxproj.filters | 6 -- 25 files changed, 146 insertions(+), 394 deletions(-) delete mode 100644 src/core/surface/client.c delete mode 100644 src/core/surface/client.h diff --git a/BUILD b/BUILD index 745b62933f7..29cc77374e4 100644 --- a/BUILD +++ b/BUILD @@ -208,7 +208,6 @@ cc_library( "src/core/surface/byte_buffer_queue.h", "src/core/surface/call.h", "src/core/surface/channel.h", - "src/core/surface/client.h", "src/core/surface/completion_queue.h", "src/core/surface/event_string.h", "src/core/surface/init.h", @@ -333,7 +332,6 @@ cc_library( "src/core/surface/call_log_batch.c", "src/core/surface/channel.c", "src/core/surface/channel_create.c", - "src/core/surface/client.c", "src/core/surface/completion_queue.c", "src/core/surface/event_string.c", "src/core/surface/init.c", @@ -456,7 +454,6 @@ cc_library( "src/core/surface/byte_buffer_queue.h", "src/core/surface/call.h", "src/core/surface/channel.h", - "src/core/surface/client.h", "src/core/surface/completion_queue.h", "src/core/surface/event_string.h", "src/core/surface/init.h", @@ -559,7 +556,6 @@ cc_library( "src/core/surface/call_log_batch.c", "src/core/surface/channel.c", "src/core/surface/channel_create.c", - "src/core/surface/client.c", "src/core/surface/completion_queue.c", "src/core/surface/event_string.c", "src/core/surface/init.c", diff --git a/Makefile b/Makefile index 283f3c6cd08..7ca182d9de6 100644 --- a/Makefile +++ b/Makefile @@ -3083,7 +3083,6 @@ LIBGRPC_SRC = \ src/core/surface/call_log_batch.c \ src/core/surface/channel.c \ src/core/surface/channel_create.c \ - src/core/surface/client.c \ src/core/surface/completion_queue.c \ src/core/surface/event_string.c \ src/core/surface/init.c \ @@ -3341,7 +3340,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/surface/call_log_batch.c \ src/core/surface/channel.c \ src/core/surface/channel_create.c \ - src/core/surface/client.c \ src/core/surface/completion_queue.c \ src/core/surface/event_string.c \ src/core/surface/init.c \ diff --git a/build.json b/build.json index b05f423c832..dc3d2ac1c57 100644 --- a/build.json +++ b/build.json @@ -169,7 +169,6 @@ "src/core/surface/byte_buffer_queue.h", "src/core/surface/call.h", "src/core/surface/channel.h", - "src/core/surface/client.h", "src/core/surface/completion_queue.h", "src/core/surface/event_string.h", "src/core/surface/init.h", @@ -272,7 +271,6 @@ "src/core/surface/call_log_batch.c", "src/core/surface/channel.c", "src/core/surface/channel_create.c", - "src/core/surface/client.c", "src/core/surface/completion_queue.c", "src/core/surface/event_string.c", "src/core/surface/init.c", diff --git a/gRPC.podspec b/gRPC.podspec index f8b5a99bdc4..1707ee7eaac 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -210,7 +210,6 @@ Pod::Spec.new do |s| 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', - 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', @@ -342,7 +341,6 @@ Pod::Spec.new do |s| 'src/core/surface/call_log_batch.c', 'src/core/surface/channel.c', 'src/core/surface/channel_create.c', - 'src/core/surface/client.c', 'src/core/surface/completion_queue.c', 'src/core/surface/event_string.c', 'src/core/surface/init.c', @@ -464,7 +462,6 @@ Pod::Spec.new do |s| 'src/core/surface/byte_buffer_queue.h', 'src/core/surface/call.h', 'src/core/surface/channel.h', - 'src/core/surface/client.h', 'src/core/surface/completion_queue.h', 'src/core/surface/event_string.h', 'src/core/surface/init.h', diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 6fad077c626..1d30b073abb 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -61,36 +61,21 @@ typedef struct connected_channel_call_data { void *unused; } call_data; /* Intercept a call operation and either push it directly up or translate it into transport stream operations */ -static void con_start_transport_op(grpc_call_element *elem, - grpc_transport_stream_op *op) { +static void con_start_transport_stream_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - grpc_transport_perform_op(chand->transport, - TRANSPORT_STREAM_FROM_CALL_DATA(calld), op); + grpc_transport_perform_stream_op(chand->transport, + TRANSPORT_STREAM_FROM_CALL_DATA(calld), op); } -/* Currently we assume all channel operations should just be pushed up. */ -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { +static void con_start_transport_op(grpc_channel_element *elem, + grpc_transport_op *op) { channel_data *chand = elem->channel_data; - GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); - - switch (op->type) { - case GRPC_CHANNEL_GOAWAY: - grpc_transport_goaway(chand->transport, op->data.goaway.status, - op->data.goaway.message); - break; - case GRPC_CHANNEL_DISCONNECT: - grpc_transport_close(chand->transport); - break; - default: - GPR_ASSERT(op->dir == GRPC_CALL_UP); - grpc_channel_next_op(elem, op); - break; - } + grpc_transport_perform_op(chand->transport, op); } /* Constructor for call_data */ @@ -136,61 +121,15 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_connected_channel_filter = { - con_start_transport_op, channel_op, sizeof(call_data), init_call_elem, - destroy_call_elem, sizeof(channel_data), init_channel_elem, - destroy_channel_elem, "connected", -}; - -/* Transport callback to accept a new stream... calls up to handle it */ -static void accept_stream(void *user_data, grpc_transport *transport, - const void *transport_server_data) { - grpc_channel_element *elem = user_data; - channel_data *chand = elem->channel_data; - grpc_channel_op op; - - GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); - GPR_ASSERT(chand->transport == transport); - - op.type = GRPC_ACCEPT_CALL; - op.dir = GRPC_CALL_UP; - op.data.accept_call.transport = transport; - op.data.accept_call.transport_server_data = transport_server_data; - channel_op(elem, NULL, &op); -} - -static void transport_goaway(void *user_data, grpc_transport *transport, - grpc_status_code status, gpr_slice debug) { - /* transport got goaway ==> call up and handle it */ - grpc_channel_element *elem = user_data; - channel_data *chand = elem->channel_data; - grpc_channel_op op; - - GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); - GPR_ASSERT(chand->transport == transport); - - op.type = GRPC_TRANSPORT_GOAWAY; - op.dir = GRPC_CALL_UP; - op.data.goaway.status = status; - op.data.goaway.message = debug; - channel_op(elem, NULL, &op); -} - -static void transport_closed(void *user_data, grpc_transport *transport) { - /* transport was closed ==> call up and handle it */ - grpc_channel_element *elem = user_data; - channel_data *chand = elem->channel_data; - grpc_channel_op op; - - GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); - GPR_ASSERT(chand->transport == transport); - - op.type = GRPC_TRANSPORT_CLOSED; - op.dir = GRPC_CALL_UP; - channel_op(elem, NULL, &op); -} - -const grpc_transport_callbacks connected_channel_transport_callbacks = { - accept_stream, transport_goaway, transport_closed, + con_start_transport_stream_op, + con_start_transport_op, + sizeof(call_data), + init_call_elem, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + "connected", }; grpc_transport_setup_result grpc_connected_channel_bind_transport( @@ -213,6 +152,5 @@ grpc_transport_setup_result grpc_connected_channel_bind_transport( channel_stack->call_stack_size += grpc_transport_stream_size(transport); ret.user_data = elem; - ret.callbacks = &connected_channel_transport_callbacks; return ret; } diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index 3f10c4fc887..6928a59c38a 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -134,23 +134,6 @@ static void hc_start_transport_op(grpc_call_element *elem, grpc_call_next_op(elem, op); } -/* Called on special channel events, such as disconnection or new incoming - calls on the server */ -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - /* grab pointers to our data from the channel element */ - channel_data *channeld = elem->channel_data; - - ignore_unused(channeld); - - switch (op->type) { - default: - /* pass control up or down the stack depending on op->dir */ - grpc_channel_next_op(elem, op); - break; - } -} - /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, @@ -222,6 +205,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_http_client_filter = { - hc_start_transport_op, channel_op, sizeof(call_data), init_call_elem, - destroy_call_elem, sizeof(channel_data), init_channel_elem, - destroy_channel_elem, "http-client"}; + hc_start_transport_op, grpc_channel_next_op, sizeof(call_data), + init_call_elem, destroy_call_elem, sizeof(channel_data), + init_channel_elem, destroy_channel_elem, "http-client"}; diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c index 6434502bdc7..dac53e9bf1a 100644 --- a/src/core/channel/http_server_filter.c +++ b/src/core/channel/http_server_filter.c @@ -72,9 +72,6 @@ typedef struct channel_data { grpc_mdctx *mdctx; } channel_data; -/* used to silence 'variable not used' warnings */ -static void ignore_unused(void *ignored) {} - static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { grpc_call_element *elem = user_data; channel_data *channeld = elem->channel_data; @@ -216,23 +213,6 @@ static void hs_start_transport_op(grpc_call_element *elem, grpc_call_next_op(elem, op); } -/* Called on special channel events, such as disconnection or new incoming - calls on the server */ -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - /* grab pointers to our data from the channel element */ - channel_data *channeld = elem->channel_data; - - ignore_unused(channeld); - - switch (op->type) { - default: - /* pass control up or down the stack depending on op->dir */ - grpc_channel_next_op(elem, op); - break; - } -} - /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, @@ -298,6 +278,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_http_server_filter = { - hs_start_transport_op, channel_op, sizeof(call_data), init_call_elem, - destroy_call_elem, sizeof(channel_data), init_channel_elem, - destroy_channel_elem, "http-server"}; + hs_start_transport_op, grpc_channel_next_op, sizeof(call_data), + init_call_elem, destroy_call_elem, sizeof(channel_data), + init_channel_elem, destroy_channel_elem, "http-server"}; diff --git a/src/core/channel/noop_filter.c b/src/core/channel/noop_filter.c index d472b807440..1478f04a3c2 100644 --- a/src/core/channel/noop_filter.c +++ b/src/core/channel/noop_filter.c @@ -62,31 +62,14 @@ static void noop_mutate_op(grpc_call_element *elem, - a network event (or similar) from below, to receive something op contains type and call direction information, in addition to the data that is being sent or received. */ -static void noop_start_transport_op(grpc_call_element *elem, - grpc_transport_stream_op *op) { +static void noop_start_transport_stream_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { noop_mutate_op(elem, op); /* pass control down the stack */ grpc_call_next_op(elem, op); } -/* Called on special channel events, such as disconnection or new incoming - calls on the server */ -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - /* grab pointers to our data from the channel element */ - channel_data *channeld = elem->channel_data; - - ignore_unused(channeld); - - switch (op->type) { - default: - /* pass control up or down the stack depending on op->dir */ - grpc_channel_next_op(elem, op); - break; - } -} - /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, @@ -136,7 +119,12 @@ static void destroy_channel_elem(grpc_channel_element *elem) { ignore_unused(channeld); } -const grpc_channel_filter grpc_no_op_filter = { - noop_start_transport_op, channel_op, sizeof(call_data), init_call_elem, - destroy_call_elem, sizeof(channel_data), init_channel_elem, - destroy_channel_elem, "no-op"}; +const grpc_channel_filter grpc_no_op_filter = {noop_start_transport_stream_op, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + "no-op"}; diff --git a/src/core/surface/call.c b/src/core/surface/call.c index ddff3efb324..7a8eb8c54fe 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -1154,7 +1154,7 @@ static void execute_op(grpc_call *call, grpc_transport_stream_op *op) { elem = CALL_ELEM_FROM_CALL(call, 0); op->context = call->context; - elem->filter->start_transport_op(elem, op); + elem->filter->start_transport_stream_op(elem, op); } grpc_call *grpc_call_from_top_element(grpc_call_element *elem) { diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index a3c4dcebc15..6c4b407a850 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -39,7 +39,6 @@ #include "src/core/iomgr/iomgr.h" #include "src/core/support/string.h" #include "src/core/surface/call.h" -#include "src/core/surface/client.h" #include "src/core/surface/init.h" #include #include @@ -238,22 +237,15 @@ void grpc_channel_internal_unref(grpc_channel *channel) { } } -void grpc_channel_destroy(grpc_channel *channel) { - grpc_channel_op op; - grpc_channel_element *elem; - - elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0); - - op.type = GRPC_CHANNEL_GOAWAY; - op.dir = GRPC_CALL_DOWN; - op.data.goaway.status = GRPC_STATUS_OK; - op.data.goaway.message = gpr_slice_from_copied_string("Client disconnect"); - elem->filter->channel_op(elem, NULL, &op); - - op.type = GRPC_CHANNEL_DISCONNECT; - op.dir = GRPC_CALL_DOWN; - elem->filter->channel_op(elem, NULL, &op); +static void execute_op(grpc_channel *channel, grpc_transport_op *op) { + abort(); +} +void grpc_channel_destroy(grpc_channel *channel) { + grpc_transport_op op; + memset(&op, 0, sizeof(op)); + op.disconnect = 1; + execute_op(channel, &op); GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel"); } diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 8efd86b9f67..14ff63a2e38 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -38,9 +38,7 @@ #include "src/core/channel/client_channel.h" #include "src/core/client_config/resolver_registry.h" -#include "src/core/client_config/subchannels/tcp_subchannel.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" /* Create a client channel: Asynchronously: - resolve target @@ -53,7 +51,6 @@ grpc_channel *grpc_channel_create(const char *target, const grpc_channel_filter *filters[MAX_FILTERS]; grpc_resolver *resolver; int n = 0; - filters[n++] = &grpc_client_surface_filter; /* TODO(census) if (grpc_channel_args_is_census_enabled(args)) { filters[n++] = &grpc_client_census_filter; @@ -61,7 +58,8 @@ grpc_channel *grpc_channel_create(const char *target, filters[n++] = &grpc_client_channel_filter; GPR_ASSERT(n <= MAX_FILTERS); - resolver = grpc_resolver_create(target, grpc_create_tcp_subchannel_factory()); + GPR_ASSERT(!"NULL should be a subchannel factory creation below"); + resolver = grpc_resolver_create(target, NULL); if (!resolver) { return NULL; } diff --git a/src/core/surface/client.c b/src/core/surface/client.c deleted file mode 100644 index 9c9cba57715..00000000000 --- a/src/core/surface/client.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/surface/client.h" - -#include "src/core/surface/call.h" -#include "src/core/surface/channel.h" -#include "src/core/support/string.h" -#include -#include - -typedef struct { void *unused; } call_data; - -typedef struct { void *unused; } channel_data; - -static void client_start_transport_op(grpc_call_element *elem, - grpc_transport_stream_op *op) { - GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - grpc_call_next_op(elem, op); -} - -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - switch (op->type) { - case GRPC_ACCEPT_CALL: - gpr_log(GPR_ERROR, "Client cannot accept new calls"); - break; - case GRPC_TRANSPORT_CLOSED: - grpc_client_channel_closed(elem); - break; - case GRPC_TRANSPORT_GOAWAY: - gpr_slice_unref(op->data.goaway.message); - break; - default: - GPR_ASSERT(op->dir == GRPC_CALL_DOWN); - grpc_channel_next_op(elem, op); - } -} - -static void init_call_elem(grpc_call_element *elem, - const void *transport_server_data, - grpc_transport_stream_op *initial_op) {} - -static void destroy_call_elem(grpc_call_element *elem) {} - -static void init_channel_elem(grpc_channel_element *elem, - const grpc_channel_args *args, grpc_mdctx *mdctx, - int is_first, int is_last) { - GPR_ASSERT(is_first); - GPR_ASSERT(!is_last); -} - -static void destroy_channel_elem(grpc_channel_element *elem) {} - -const grpc_channel_filter grpc_client_surface_filter = { - client_start_transport_op, channel_op, sizeof(call_data), init_call_elem, - destroy_call_elem, sizeof(channel_data), init_channel_elem, - destroy_channel_elem, "client", -}; diff --git a/src/core/surface/client.h b/src/core/surface/client.h deleted file mode 100644 index 9db2ccf3d28..00000000000 --- a/src/core/surface/client.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_INTERNAL_CORE_SURFACE_CLIENT_H -#define GRPC_INTERNAL_CORE_SURFACE_CLIENT_H - -#include "src/core/channel/channel_stack.h" - -extern const grpc_channel_filter grpc_client_surface_filter; - -#endif /* GRPC_INTERNAL_CORE_SURFACE_CLIENT_H */ diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index 4b55e9dc91a..5235d3f7f41 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -49,16 +49,16 @@ typedef struct { typedef struct { grpc_mdctx *mdctx; } channel_data; -static void lame_start_transport_op(grpc_call_element *elem, - grpc_transport_stream_op *op) { +static void lame_start_transport_stream_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - if (op->send_ops) { + if (op->send_ops != NULL) { grpc_stream_ops_unref_owned_objects(op->send_ops->ops, op->send_ops->nops); op->on_done_send->cb(op->on_done_send->cb_arg, 0); } - if (op->recv_ops) { + if (op->recv_ops != NULL) { char tmp[GPR_LTOA_MIN_BUFSIZE]; grpc_metadata_batch mdb; gpr_ltoa(GRPC_STATUS_UNKNOWN, tmp); @@ -77,22 +77,21 @@ static void lame_start_transport_op(grpc_call_element *elem, *op->recv_state = GRPC_STREAM_CLOSED; op->on_done_recv->cb(op->on_done_recv->cb_arg, 1); } - if (op->on_consumed) { + if (op->on_consumed != NULL) { op->on_consumed->cb(op->on_consumed->cb_arg, 0); } } -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - switch (op->type) { - case GRPC_CHANNEL_GOAWAY: - gpr_slice_unref(op->data.goaway.message); - break; - case GRPC_CHANNEL_DISCONNECT: - grpc_client_channel_closed(elem); - break; - default: - break; +static void lame_start_transport_op(grpc_channel_element *elem, + grpc_transport_op *op) { + if (op->on_connectivity_state_change) { + GPR_ASSERT(*op->connectivity_state != GRPC_CHANNEL_FATAL_FAILURE); + *op->connectivity_state = GRPC_CHANNEL_FATAL_FAILURE; + op->on_connectivity_state_change->cb( + op->on_connectivity_state_change->cb_arg, 1); + } + if (op->on_consumed != NULL) { + op->on_consumed->cb(op->on_consumed->cb_arg, 1); } } @@ -118,9 +117,15 @@ static void init_channel_elem(grpc_channel_element *elem, static void destroy_channel_elem(grpc_channel_element *elem) {} static const grpc_channel_filter lame_filter = { - lame_start_transport_op, channel_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "lame-client", + lame_start_transport_stream_op, + lame_start_transport_op, + sizeof(call_data), + init_call_elem, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + "lame-client", }; grpc_channel *grpc_lame_client_channel_create(void) { diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 607344a7a6a..568f7925dd5 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -115,6 +115,7 @@ typedef struct channel_registered_method { struct channel_data { grpc_server *server; size_t num_calls; + grpc_connectivity_state connectivity_state; grpc_channel *channel; grpc_mdstr *path_key; grpc_mdstr *authority_key; @@ -125,6 +126,7 @@ struct channel_data { gpr_uint32 registered_method_slots; gpr_uint32 registered_method_max_probes; grpc_iomgr_closure finish_destroy_channel_closure; + grpc_iomgr_closure channel_connectivity_changed; }; typedef struct shutdown_tag { @@ -539,13 +541,41 @@ static void server_mutate_op(grpc_call_element *elem, } } -static void server_start_transport_op(grpc_call_element *elem, - grpc_transport_stream_op *op) { +static void server_start_transport_stream_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { GRPC_CALL_LOG_OP(GPR_INFO, elem, op); server_mutate_op(elem, op); grpc_call_next_op(elem, op); } +static void accept_stream(void *cd, grpc_transport *transport, + const void *transport_server_data) { + channel_data *chand = cd; + /* create a call */ + grpc_call_create(chand->channel, NULL, transport_server_data, NULL, 0, + gpr_inf_future); +} + +static void channel_connectivity_changed(void *cd, int iomgr_status_ignored) { + channel_data *chand = cd; + grpc_server *server = chand->server; + if (chand->connectivity_state != GRPC_CHANNEL_FATAL_FAILURE) { + grpc_transport_op op; + memset(&op, 0, sizeof(op)); + op.on_connectivity_state_change = &chand->channel_connectivity_changed, + op.connectivity_state = &chand->connectivity_state; + grpc_channel_next_op(grpc_channel_stack_element( + grpc_channel_get_channel_stack(chand->channel), 0), + &op); + } else { + gpr_mu_lock(&server->mu_global); + destroy_channel(chand); + gpr_mu_unlock(&server->mu_global); + GRPC_CHANNEL_INTERNAL_UNREF(chand->channel, "connectivity"); + } +} + +#if 0 static void channel_op(grpc_channel_element *elem, grpc_channel_element *from_elem, grpc_channel_op *op) { channel_data *chand = elem->channel_data; @@ -576,39 +606,45 @@ static void channel_op(grpc_channel_element *elem, break; } } +#endif typedef struct { channel_data *chand; int send_goaway; int send_disconnect; grpc_iomgr_closure finish_shutdown_channel_closure; + + /* for use during shutdown: the goaway message to send */ + gpr_slice goaway_message; } shutdown_channel_args; -static void finish_shutdown_channel(void *p, int success) { +static void destroy_shutdown_channel_args(void *p, int success) { shutdown_channel_args *sca = p; - grpc_channel_op op; - - if (sca->send_goaway) { - op.type = GRPC_CHANNEL_GOAWAY; - op.dir = GRPC_CALL_DOWN; - op.data.goaway.status = GRPC_STATUS_OK; - op.data.goaway.message = gpr_slice_from_copied_string("Server shutdown"); - channel_op(grpc_channel_stack_element( - grpc_channel_get_channel_stack(sca->chand->channel), 0), - NULL, &op); - } - if (sca->send_disconnect) { - op.type = GRPC_CHANNEL_DISCONNECT; - op.dir = GRPC_CALL_DOWN; - channel_op(grpc_channel_stack_element( - grpc_channel_get_channel_stack(sca->chand->channel), 0), - NULL, &op); - } GRPC_CHANNEL_INTERNAL_UNREF(sca->chand->channel, "shutdown"); - + gpr_slice_unref(sca->goaway_message); gpr_free(sca); } +static void finish_shutdown_channel(void *p, int success) { + shutdown_channel_args *sca = p; + grpc_transport_op op; + memset(&op, 0, sizeof(op)); + + op.send_goaway = sca->send_goaway; + sca->goaway_message = gpr_slice_from_copied_string("Server shutdown"); + op.goaway_message = &sca->goaway_message; + op.goaway_status = GRPC_STATUS_OK; + op.disconnect = sca->send_disconnect; + grpc_iomgr_closure_init(&sca->finish_shutdown_channel_closure, + destroy_shutdown_channel_args, sca); + op.on_consumed = &sca->finish_shutdown_channel_closure; + + grpc_channel_next_op( + grpc_channel_stack_element( + grpc_channel_get_channel_stack(sca->chand->channel), 0), + &op); +} + static void shutdown_channel(channel_data *chand, int send_goaway, int send_disconnect) { shutdown_channel_args *sca; @@ -687,6 +723,9 @@ static void init_channel_elem(grpc_channel_element *elem, chand->authority_key = grpc_mdstr_from_string(metadata_context, ":authority"); chand->next = chand->prev = chand; chand->registered_methods = NULL; + chand->connectivity_state = GRPC_CHANNEL_IDLE; + grpc_iomgr_closure_init(&chand->channel_connectivity_changed, + channel_connectivity_changed, chand); } static void destroy_channel_elem(grpc_channel_element *elem) { @@ -717,8 +756,8 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } static const grpc_channel_filter server_surface_filter = { - server_start_transport_op, - channel_op, + server_start_transport_stream_op, + grpc_channel_next_op, sizeof(call_data), init_call_elem, destroy_call_elem, @@ -852,6 +891,7 @@ grpc_transport_setup_result grpc_server_setup_transport( gpr_uint32 slots; gpr_uint32 probes; gpr_uint32 max_probes = 0; + grpc_transport_op op; grpc_transport_setup_result result; for (i = 0; i < s->channel_filter_count; i++) { @@ -863,7 +903,9 @@ grpc_transport_setup_result grpc_server_setup_transport( filters[i] = &grpc_connected_channel_filter; for (i = 0; i < s->cq_count; i++) { - grpc_transport_add_to_pollset(transport, grpc_cq_pollset(s->cqs[i])); + memset(&op, 0, sizeof(op)); + op.bind_pollset = grpc_cq_pollset(s->cqs[i]); + grpc_transport_perform_op(transport, &op); } channel = @@ -875,6 +917,14 @@ grpc_transport_setup_result grpc_server_setup_transport( server_ref(s); chand->channel = channel; + GRPC_CHANNEL_INTERNAL_REF(channel, "connectivity"); + memset(&op, 0, sizeof(op)); + op.set_accept_stream = accept_stream; + op.set_accept_stream_user_data = chand; + op.on_connectivity_state_change = &chand->channel_connectivity_changed; + op.connectivity_state = &chand->connectivity_state; + grpc_transport_perform_op(transport, &op); + num_registered_methods = 0; for (rm = s->registered_methods; rm; rm = rm->next) { num_registered_methods++; diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 685098bcba9..f2568c01e02 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -1038,11 +1038,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *reason, static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream), init_stream, perform_op, - add_to_pollset, destroy_stream, - goaway, - close_transport, - send_ping, destroy_transport}; void grpc_create_chttp2_transport(grpc_transport_setup_callback setup, diff --git a/src/core/transport/transport.c b/src/core/transport/transport.c index 40faa272111..a570cba33e8 100644 --- a/src/core/transport/transport.c +++ b/src/core/transport/transport.c @@ -38,15 +38,6 @@ size_t grpc_transport_stream_size(grpc_transport *transport) { return transport->vtable->sizeof_stream; } -void grpc_transport_goaway(grpc_transport *transport, grpc_status_code status, - gpr_slice message) { - transport->vtable->goaway(transport, status, message); -} - -void grpc_transport_close(grpc_transport *transport) { - transport->vtable->close(transport); -} - void grpc_transport_destroy(grpc_transport *transport) { transport->vtable->destroy(transport); } @@ -68,20 +59,11 @@ void grpc_transport_perform_op(grpc_transport *transport, transport->vtable->perform_op(transport, op); } -void grpc_transport_add_to_pollset(grpc_transport *transport, - grpc_pollset *pollset) { - transport->vtable->add_to_pollset(transport, pollset); -} - void grpc_transport_destroy_stream(grpc_transport *transport, grpc_stream *stream) { transport->vtable->destroy_stream(transport, stream); } -void grpc_transport_ping(grpc_transport *transport, grpc_iomgr_closure *cb) { - transport->vtable->ping(transport, cb); -} - void grpc_transport_setup_cancel(grpc_transport_setup *setup) { setup->vtable->cancel(setup); } diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h index 7f6a37d0481..1acd665a1df 100644 --- a/src/core/transport/transport.h +++ b/src/core/transport/transport.h @@ -85,6 +85,8 @@ typedef struct grpc_transport_stream_op { /** Transport op: a set of operations to perform on a transport as a whole */ typedef struct grpc_transport_op { + /** called when processing of this op is done */ + grpc_iomgr_closure *on_consumed; /** connectivity monitoring */ grpc_iomgr_closure *on_connectivity_state_change; grpc_connectivity_state *connectivity_state; diff --git a/src/core/transport/transport_impl.h b/src/core/transport/transport_impl.h index b65b1d56078..82839390502 100644 --- a/src/core/transport/transport_impl.h +++ b/src/core/transport/transport_impl.h @@ -52,7 +52,7 @@ typedef struct grpc_transport_vtable { /* implementation of grpc_transport_perform_op */ void (*perform_op)(grpc_transport *self, grpc_stream *stream, - grpc_transport_stream_op *op); + grpc_transport_op *op); /* implementation of grpc_transport_destroy_stream */ void (*destroy_stream)(grpc_transport *self, grpc_stream *stream); diff --git a/test/core/end2end/fixtures/chttp2_fullstack.c b/test/core/end2end/fixtures/chttp2_fullstack.c index b83e227a895..e647434509d 100644 --- a/test/core/end2end/fixtures/chttp2_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_fullstack.c @@ -39,7 +39,6 @@ #include "src/core/channel/connected_channel.h" #include "src/core/channel/http_server_filter.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" #include "src/core/surface/server.h" #include "src/core/transport/chttp2_transport.h" #include diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 4f00104c028..bc2cfaf6a47 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -845,7 +845,6 @@ src/core/profiling/timers_preciseclock.h \ src/core/surface/byte_buffer_queue.h \ src/core/surface/call.h \ src/core/surface/channel.h \ -src/core/surface/client.h \ src/core/surface/completion_queue.h \ src/core/surface/event_string.h \ src/core/surface/init.h \ @@ -970,7 +969,6 @@ src/core/surface/call_details.c \ src/core/surface/call_log_batch.c \ src/core/surface/channel.c \ src/core/surface/channel_create.c \ -src/core/surface/client.c \ src/core/surface/completion_queue.c \ src/core/surface/event_string.c \ src/core/surface/init.c \ diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 0a7da41dbf6..6c55c4f8341 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -234,7 +234,6 @@ - @@ -454,8 +453,6 @@ - - diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index 8d1815c7518..d2ada43b6db 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -280,9 +280,6 @@ src\core\surface - - src\core\surface - src\core\surface @@ -650,9 +647,6 @@ src\core\surface - - src\core\surface - src\core\surface diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index b96e3092e29..09b39972779 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -216,7 +216,6 @@ - @@ -392,8 +391,6 @@ - - diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index dd2846eef13..3b65c46f2b1 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -214,9 +214,6 @@ src\core\surface - - src\core\surface - src\core\surface @@ -533,9 +530,6 @@ src\core\surface - - src\core\surface - src\core\surface From 1064f8b97e059e1db3b7d1795748db335909ee42 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 13:52:57 -0700 Subject: [PATCH 036/124] Moving chttp2 to new transport interface --- src/core/channel/client_channel.h | 8 - src/core/channel/connected_channel.c | 8 +- src/core/channel/connected_channel.h | 4 +- src/core/surface/server.c | 15 +- src/core/surface/server.h | 8 +- src/core/surface/server_chttp2.c | 18 +- src/core/transport/chttp2/internal.h | 36 ++-- src/core/transport/chttp2_transport.c | 229 ++++++++++---------------- src/core/transport/chttp2_transport.h | 9 +- src/core/transport/transport.c | 18 -- src/core/transport/transport.h | 47 ------ src/core/transport/transport_impl.h | 3 +- 12 files changed, 122 insertions(+), 281 deletions(-) diff --git a/src/core/channel/client_channel.h b/src/core/channel/client_channel.h index da02073353f..5ab64b9c46b 100644 --- a/src/core/channel/client_channel.h +++ b/src/core/channel/client_channel.h @@ -52,12 +52,4 @@ extern const grpc_channel_filter grpc_client_channel_filter; void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, grpc_resolver *resolver); -/* grpc_transport_setup_callback for binding new transports into a client - channel - user_data should be the channel stack containing the client - channel */ -grpc_transport_setup_result grpc_client_channel_transport_setup_complete( - grpc_channel_stack *channel_stack, grpc_transport *transport, - grpc_channel_filter const **channel_filters, size_t num_channel_filters, - grpc_mdctx *mdctx); - #endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H */ diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 1d30b073abb..80a3100af05 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -132,13 +132,12 @@ const grpc_channel_filter grpc_connected_channel_filter = { "connected", }; -grpc_transport_setup_result grpc_connected_channel_bind_transport( - grpc_channel_stack *channel_stack, grpc_transport *transport) { +void grpc_connected_channel_bind_transport(grpc_channel_stack *channel_stack, + grpc_transport *transport) { /* Assumes that the connected channel filter is always the last filter in a channel stack */ grpc_channel_element *elem = grpc_channel_stack_last_element(channel_stack); channel_data *cd = (channel_data *)elem->channel_data; - grpc_transport_setup_result ret; GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); GPR_ASSERT(cd->transport == NULL); cd->transport = transport; @@ -150,7 +149,4 @@ grpc_transport_setup_result grpc_connected_channel_bind_transport( the last call element, and the last call element MUST be the connected channel. */ channel_stack->call_stack_size += grpc_transport_stream_size(transport); - - ret.user_data = elem; - return ret; } diff --git a/src/core/channel/connected_channel.h b/src/core/channel/connected_channel.h index 8b35f69b26f..d1e2c195cb7 100644 --- a/src/core/channel/connected_channel.h +++ b/src/core/channel/connected_channel.h @@ -43,7 +43,7 @@ extern const grpc_channel_filter grpc_connected_channel_filter; /* Post construction fixup: set the transport in the connected channel. Must be called before any call stack using this filter is used. */ -grpc_transport_setup_result grpc_connected_channel_bind_transport( - grpc_channel_stack *channel_stack, grpc_transport *transport); +void grpc_connected_channel_bind_transport(grpc_channel_stack *channel_stack, + grpc_transport *transport); #endif /* GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H */ diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 568f7925dd5..98e0e81eaae 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -871,10 +871,10 @@ void grpc_server_start(grpc_server *server) { } } -grpc_transport_setup_result grpc_server_setup_transport( - grpc_server *s, grpc_transport *transport, - grpc_channel_filter const **extra_filters, size_t num_extra_filters, - grpc_mdctx *mdctx, const grpc_channel_args *args) { +void grpc_server_setup_transport(grpc_server *s, grpc_transport *transport, + grpc_channel_filter const **extra_filters, + size_t num_extra_filters, grpc_mdctx *mdctx, + const grpc_channel_args *args) { size_t num_filters = s->channel_filter_count + num_extra_filters + 1; grpc_channel_filter const **filters = gpr_malloc(sizeof(grpc_channel_filter *) * num_filters); @@ -892,7 +892,6 @@ grpc_transport_setup_result grpc_server_setup_transport( gpr_uint32 probes; gpr_uint32 max_probes = 0; grpc_transport_op op; - grpc_transport_setup_result result; for (i = 0; i < s->channel_filter_count; i++) { filters[i] = s->channel_filters[i]; @@ -954,8 +953,8 @@ grpc_transport_setup_result grpc_server_setup_transport( chand->registered_method_max_probes = max_probes; } - result = grpc_connected_channel_bind_transport( - grpc_channel_get_channel_stack(channel), transport); + grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel), + transport); gpr_mu_lock(&s->mu_global); chand->next = &s->root_channel_data; @@ -964,8 +963,6 @@ grpc_transport_setup_result grpc_server_setup_transport( gpr_mu_unlock(&s->mu_global); gpr_free(filters); - - return result; } void grpc_server_shutdown_and_notify(grpc_server *server, diff --git a/src/core/surface/server.h b/src/core/surface/server.h index 91a1a2a7f65..2899c6dea38 100644 --- a/src/core/surface/server.h +++ b/src/core/surface/server.h @@ -55,10 +55,10 @@ void grpc_server_listener_destroy_done(void *server); /* Setup a transport - creates a channel stack, binds the transport to the server */ -grpc_transport_setup_result grpc_server_setup_transport( - grpc_server *server, grpc_transport *transport, - grpc_channel_filter const **extra_filters, size_t num_extra_filters, - grpc_mdctx *mdctx, const grpc_channel_args *args); +void grpc_server_setup_transport(grpc_server *server, grpc_transport *transport, + grpc_channel_filter const **extra_filters, + size_t num_extra_filters, grpc_mdctx *mdctx, + const grpc_channel_args *args); const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server); diff --git a/src/core/surface/server_chttp2.c b/src/core/surface/server_chttp2.c index 7e49a531df2..9c02c3ef297 100644 --- a/src/core/surface/server_chttp2.c +++ b/src/core/surface/server_chttp2.c @@ -42,14 +42,13 @@ #include #include -static grpc_transport_setup_result setup_transport(void *server, - grpc_transport *transport, - grpc_mdctx *mdctx) { +static void setup_transport(void *server, grpc_transport *transport, + grpc_mdctx *mdctx) { static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; - return grpc_server_setup_transport(server, transport, extra_filters, - GPR_ARRAY_SIZE(extra_filters), mdctx, - grpc_server_get_channel_args(server)); + grpc_server_setup_transport(server, transport, extra_filters, + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(server)); } static void new_transport(void *server, grpc_endpoint *tcp) { @@ -60,9 +59,10 @@ static void new_transport(void *server, grpc_endpoint *tcp) { * (as in server_secure_chttp2.c) needs to add synchronization to avoid this * case. */ - grpc_create_chttp2_transport(setup_transport, server, - grpc_server_get_channel_args(server), tcp, NULL, - 0, grpc_mdctx_create(), 0); + grpc_mdctx *mdctx = grpc_mdctx_create(); + grpc_transport *transport = grpc_create_chttp2_transport( + grpc_server_get_channel_args(server), tcp, NULL, 0, mdctx, 0); + setup_transport(server, transport, mdctx); } /* Server callback: start listening on our ports */ diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h index 02c94744ee2..93235aef552 100644 --- a/src/core/transport/chttp2/internal.h +++ b/src/core/transport/chttp2/internal.h @@ -134,12 +134,6 @@ typedef struct { grpc_chttp2_stream *prev; } grpc_chttp2_stream_link; -typedef enum { - GRPC_CHTTP2_ERROR_STATE_NONE, - GRPC_CHTTP2_ERROR_STATE_SEEN, - GRPC_CHTTP2_ERROR_STATE_NOTIFIED -} grpc_chttp2_error_state; - /* We keep several sets of connection wide parameters */ typedef enum { /* The settings our peer has asked for (and we have acked) */ @@ -174,6 +168,9 @@ typedef struct { /** how much window would we like to have for incoming_window */ gpr_uint32 connection_window_target; + /** have we seen a goaway */ + gpr_uint8 seen_goaway; + /** is this transport a client? */ gpr_uint8 is_client; /** are the local settings dirty and need to be sent? */ @@ -185,10 +182,6 @@ typedef struct { /** settings values */ gpr_uint32 settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS]; - /** has there been a connection level error, and have we notified - anyone about it? */ - grpc_chttp2_error_state error_state; - /** what is the next stream id to be allocated by this peer? copied to next_stream_id in parsing when parsing commences */ gpr_uint32 next_stream_id; @@ -204,13 +197,6 @@ typedef struct { /** concurrent stream count: updated when not parsing, so this is a strict over-estimation on the client */ gpr_uint32 concurrent_stream_count; - - /** is there a goaway available? (boolean) */ - grpc_chttp2_error_state goaway_state; - /** what is the debug text of the goaway? */ - gpr_slice goaway_text; - /** what is the status code of the goaway? */ - grpc_status_code goaway_error; } grpc_chttp2_transport_global; typedef struct { @@ -343,14 +329,14 @@ struct grpc_chttp2_transport { grpc_chttp2_stream **accepting_stream; struct { - /** is a thread currently performing channel callbacks */ - gpr_uint8 executing; - /** transport channel-level callback */ - const grpc_transport_callbacks *cb; - /** user data for cb calls */ - void *cb_user_data; - /** closure for notifying transport closure */ - grpc_iomgr_closure notify_closed; + /* accept stream callback */ + void (*accept_stream)(void *user_data, grpc_transport *transport, + const void *server_data); + void *accept_stream_user_data; + + /** connectivity tracking */ + grpc_iomgr_closure *on_connectivity_changed; + grpc_connectivity_state *connectivity; } channel_callback; }; diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 6e61af6f191..11dd60bbb9c 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -87,7 +87,6 @@ static void unlock_check_read_write_state(grpc_chttp2_transport *t); /* forward declarations of various callbacks that we'll build closures around */ static void writing_action(void *t, int iomgr_success_ignored); static void reading_action(void *t, int iomgr_success_ignored); -static void notify_closed(void *t, int iomgr_success_ignored); /** Set a transport level setting, and push it to our peer */ static void push_setting(grpc_chttp2_transport *t, grpc_chttp2_setting_id id, @@ -101,9 +100,9 @@ static void recv_data(void *tp, gpr_slice *slices, size_t nslices, static void drop_connection(grpc_chttp2_transport *t); /** Perform a transport_op */ -static void perform_op_locked(grpc_chttp2_transport_global *transport_global, - grpc_chttp2_stream_global *stream_global, - grpc_transport_stream_op *op); +static void perform_stream_op_locked( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global *stream_global, grpc_transport_stream_op *op); /** Cancel a stream: coming from the transport API */ static void cancel_from_api(grpc_chttp2_transport_global *transport_global, @@ -198,13 +197,11 @@ static void ref_transport(grpc_chttp2_transport *t) { gpr_ref(&t->refs); } #endif static void init_transport(grpc_chttp2_transport *t, - grpc_transport_setup_callback setup, void *arg, const grpc_channel_args *channel_args, grpc_endpoint *ep, gpr_slice *slices, size_t nslices, grpc_mdctx *mdctx, int is_client) { size_t i; int j; - grpc_transport_setup_result sr; GPR_ASSERT(strlen(GRPC_CHTTP2_CLIENT_CONNECT_STRING) == GRPC_CHTTP2_CLIENT_CONNECT_STRLEN); @@ -219,7 +216,6 @@ static void init_transport(grpc_chttp2_transport *t, grpc_mdctx_ref(mdctx); t->metadata_context = mdctx; t->endpoint_reading = 1; - t->global.error_state = GRPC_CHTTP2_ERROR_STATE_NONE; t->global.next_stream_id = is_client ? 1 : 2; t->global.is_client = is_client; t->global.outgoing_window = DEFAULT_WINDOW; @@ -245,7 +241,6 @@ static void init_transport(grpc_chttp2_transport *t, grpc_chttp2_goaway_parser_init(&t->parsing.goaway_parser); grpc_chttp2_hpack_parser_init(&t->parsing.hpack_parser, t->metadata_context); - grpc_iomgr_closure_init(&t->channel_callback.notify_closed, notify_closed, t); if (is_client) { gpr_slice_buffer_add( &t->global.qbuf, @@ -312,23 +307,8 @@ static void init_transport(grpc_chttp2_transport *t, } } - gpr_mu_lock(&t->mu); - t->channel_callback.executing = 1; - REF_TRANSPORT(t, "init"); /* matches unref at end of this function */ - gpr_mu_unlock(&t->mu); - - sr = setup(arg, &t->base, t->metadata_context); - - lock(t); - t->channel_callback.cb = sr.callbacks; - t->channel_callback.cb_user_data = sr.user_data; - t->channel_callback.executing = 0; - unlock(t); - REF_TRANSPORT(t, "recv_data"); /* matches unref inside recv_data */ recv_data(t, slices, nslices, GRPC_ENDPOINT_CB_OK); - - UNREF_TRANSPORT(t, "init"); } static void destroy_transport(grpc_transport *gt) { @@ -351,23 +331,6 @@ static void close_transport_locked(grpc_chttp2_transport *t) { } } -static void close_transport(grpc_transport *gt) { - grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; - gpr_mu_lock(&t->mu); - close_transport_locked(t); - gpr_mu_unlock(&t->mu); -} - -static void goaway(grpc_transport *gt, grpc_status_code status, - gpr_slice debug_data) { - grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; - lock(t); - grpc_chttp2_goaway_append(t->global.last_incoming_stream_id, - grpc_chttp2_grpc_status_to_http2_error(status), - debug_data, &t->global.qbuf); - unlock(t); -} - static int init_stream(grpc_transport *gt, grpc_stream *gs, const void *server_data, grpc_transport_stream_op *initial_op) { grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; @@ -399,7 +362,7 @@ static int init_stream(grpc_transport *gt, grpc_stream *gs, s->global.in_stream_map = 1; } - if (initial_op) perform_op_locked(&t->global, &s->global, initial_op); + if (initial_op) perform_stream_op_locked(&t->global, &s->global, initial_op); unlock(t); return 0; @@ -454,8 +417,8 @@ grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream( grpc_chttp2_transport *t = TRANSPORT_FROM_PARSING(transport_parsing); GPR_ASSERT(t->accepting_stream == NULL); t->accepting_stream = &accepting; - t->channel_callback.cb->accept_stream(t->channel_callback.cb_user_data, - &t->base, (void *)(gpr_uintptr)id); + t->channel_callback.accept_stream(t->channel_callback.accept_stream_user_data, + &t->base, (void *)(gpr_uintptr)id); t->accepting_stream = NULL; return &accepting->parsing; } @@ -476,7 +439,7 @@ static void unlock(grpc_chttp2_transport *t) { grpc_iomgr_closure *run_closures; unlock_check_read_write_state(t); - if (!t->writing_active && t->global.error_state == GRPC_CHTTP2_ERROR_STATE_NONE && + if (!t->writing_active && !t->closed && grpc_chttp2_unlocking_check_writes(&t->global, &t->writing)) { t->writing_active = 1; REF_TRANSPORT(t, "writing"); @@ -553,14 +516,10 @@ void grpc_chttp2_add_incoming_goaway( grpc_chttp2_transport_global *transport_global, gpr_uint32 goaway_error, gpr_slice goaway_text) { char *msg = gpr_hexdump((char*)GPR_SLICE_START_PTR(goaway_text), GPR_SLICE_LENGTH(goaway_text), GPR_HEXDUMP_PLAINTEXT); + gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg); gpr_free(msg); - if (transport_global->goaway_state == GRPC_CHTTP2_ERROR_STATE_NONE) { - transport_global->goaway_state = GRPC_CHTTP2_ERROR_STATE_SEEN; - transport_global->goaway_text = goaway_text; - transport_global->goaway_error = goaway_error; - } else { - gpr_slice_unref(goaway_text); - } + gpr_slice_unref(goaway_text); + transport_global->seen_goaway = 1; } static void maybe_start_some_streams( @@ -613,9 +572,9 @@ static void maybe_start_some_streams( } } -static void perform_op_locked(grpc_chttp2_transport_global *transport_global, - grpc_chttp2_stream_global *stream_global, - grpc_transport_stream_op *op) { +static void perform_stream_op_locked( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global *stream_global, grpc_transport_stream_op *op) { if (op->cancel_with_status != GRPC_STATUS_OK) { cancel_from_api(transport_global, stream_global, op->cancel_with_status); } @@ -672,21 +631,19 @@ static void perform_op_locked(grpc_chttp2_transport_global *transport_global, } } -static void perform_op(grpc_transport *gt, grpc_stream *gs, - grpc_transport_stream_op *op) { +static void perform_stream_op(grpc_transport *gt, grpc_stream *gs, + grpc_transport_stream_op *op) { grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs; lock(t); - perform_op_locked(&t->global, &s->global, op); + perform_stream_op_locked(&t->global, &s->global, op); unlock(t); } -static void send_ping(grpc_transport *gt, grpc_iomgr_closure *on_recv) { - grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; +static void send_ping_locked(grpc_chttp2_transport *t, + grpc_iomgr_closure *on_recv) { grpc_chttp2_outstanding_ping *p = gpr_malloc(sizeof(*p)); - - lock(t); p->next = &t->global.pings; p->prev = p->next->prev; p->prev->next = p->next->prev = p; @@ -700,6 +657,49 @@ static void send_ping(grpc_transport *gt, grpc_iomgr_closure *on_recv) { p->id[7] = t->global.ping_counter & 0xff; p->on_recv = on_recv; gpr_slice_buffer_add(&t->global.qbuf, grpc_chttp2_ping_create(0, p->id)); +} + +static void perform_transport_op(grpc_transport *gt, grpc_transport_op *op) { + grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; + + lock(t); + + if (op->on_consumed) { + grpc_chttp2_schedule_closure(&t->global, op->on_consumed, 1); + } + + if (op->on_connectivity_state_change) { + GPR_ASSERT(t->channel_callback.on_connectivity_changed == NULL); + t->channel_callback.on_connectivity_changed = + op->on_connectivity_state_change; + t->channel_callback.connectivity = op->connectivity_state; + } + + if (op->send_goaway) { + grpc_chttp2_goaway_append( + t->global.last_incoming_stream_id, + grpc_chttp2_grpc_status_to_http2_error(op->goaway_status), + *op->goaway_message, &t->global.qbuf); + } + + if (op->set_accept_stream != NULL) { + t->channel_callback.accept_stream = op->set_accept_stream; + t->channel_callback.accept_stream_user_data = + op->set_accept_stream_user_data; + } + + if (op->bind_pollset) { + add_to_pollset_locked(t, op->bind_pollset); + } + + if (op->send_ping) { + send_ping_locked(t, op->send_ping); + } + + if (op->disconnect) { + close_transport_locked(t); + } + unlock(t); } @@ -839,9 +839,6 @@ static void end_all_the_calls(grpc_chttp2_transport *t) { } static void drop_connection(grpc_chttp2_transport *t) { - if (t->global.error_state == GRPC_CHTTP2_ERROR_STATE_NONE) { - t->global.error_state = GRPC_CHTTP2_ERROR_STATE_SEEN; - } close_transport_locked(t); end_all_the_calls(t); } @@ -886,7 +883,7 @@ static void recv_data(void *tp, gpr_slice *slices, size_t nslices, lock(t); i = 0; GPR_ASSERT(!t->parsing_active); - if (t->global.error_state == GRPC_CHTTP2_ERROR_STATE_NONE) { + if (!t->closed) { t->parsing_active = 1; /* merge stream lists */ grpc_chttp2_stream_map_move_into(&t->new_stream_map, @@ -931,67 +928,21 @@ static void reading_action(void *pt, int iomgr_success_ignored) { * CALLBACK LOOP */ -typedef struct { - grpc_chttp2_transport *t; - gpr_uint32 error; - gpr_slice text; - grpc_iomgr_closure closure; -} notify_goaways_args; - -static void notify_goaways(void *p, int iomgr_success_ignored) { - notify_goaways_args *a = p; - grpc_chttp2_transport *t = a->t; - - t->channel_callback.cb->goaway(t->channel_callback.cb_user_data, &t->base, - a->error, a->text); - - gpr_free(a); - - lock(t); - t->channel_callback.executing = 0; - unlock(t); - - UNREF_TRANSPORT(t, "notify_goaways"); -} - -static void notify_closed(void *gt, int iomgr_success_ignored) { - grpc_chttp2_transport *t = gt; - t->channel_callback.cb->closed(t->channel_callback.cb_user_data, &t->base); - - lock(t); - t->channel_callback.executing = 0; - unlock(t); - - UNREF_TRANSPORT(t, "notify_closed"); -} - static void unlock_check_channel_callbacks(grpc_chttp2_transport *t) { - if (t->channel_callback.executing) { - return; - } - if (t->global.goaway_state != GRPC_CHTTP2_ERROR_STATE_NONE) { - if (t->global.goaway_state == GRPC_CHTTP2_ERROR_STATE_SEEN && - t->global.error_state != GRPC_CHTTP2_ERROR_STATE_NOTIFIED) { - notify_goaways_args *a = gpr_malloc(sizeof(*a)); - a->t = t; - a->error = t->global.goaway_error; - a->text = t->global.goaway_text; - t->global.goaway_state = GRPC_CHTTP2_ERROR_STATE_NOTIFIED; - t->channel_callback.executing = 1; - grpc_iomgr_closure_init(&a->closure, notify_goaways, a); - REF_TRANSPORT(t, "notify_goaways"); - grpc_chttp2_schedule_closure(&t->global, &a->closure, 1); - return; - } else if (t->global.goaway_state != GRPC_CHTTP2_ERROR_STATE_NOTIFIED) { - return; + if (t->channel_callback.on_connectivity_changed != NULL) { + grpc_connectivity_state current; + if (t->closed || t->global.seen_goaway) { + current = GRPC_CHANNEL_FATAL_FAILURE; + } else { + current = GRPC_CHANNEL_READY; + } + if (current != *t->channel_callback.connectivity) { + *t->channel_callback.connectivity = current; + grpc_chttp2_schedule_closure( + &t->global, t->channel_callback.on_connectivity_changed, 1); + t->channel_callback.on_connectivity_changed = NULL; + t->channel_callback.connectivity = NULL; } - } - if (t->global.error_state == GRPC_CHTTP2_ERROR_STATE_SEEN) { - t->global.error_state = GRPC_CHTTP2_ERROR_STATE_NOTIFIED; - t->channel_callback.executing = 1; - REF_TRANSPORT(t, "notify_closed"); - grpc_chttp2_schedule_closure(&t->global, &t->channel_callback.notify_closed, - 1); } } @@ -1014,13 +965,6 @@ static void add_to_pollset_locked(grpc_chttp2_transport *t, } } -static void add_to_pollset(grpc_transport *gt, grpc_pollset *pollset) { - grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; - lock(t); - add_to_pollset_locked(t, pollset); - unlock(t); -} - /* * TRACING */ @@ -1056,19 +1000,14 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *reason, * INTEGRATION GLUE */ -static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream), - init_stream, - perform_op, - destroy_stream, - destroy_transport}; - -void grpc_create_chttp2_transport(grpc_transport_setup_callback setup, - void *arg, - const grpc_channel_args *channel_args, - grpc_endpoint *ep, gpr_slice *slices, - size_t nslices, grpc_mdctx *mdctx, - int is_client) { +static const grpc_transport_vtable vtable = { + sizeof(grpc_chttp2_stream), init_stream, perform_stream_op, + perform_transport_op, destroy_stream, destroy_transport}; + +grpc_transport *grpc_create_chttp2_transport( + const grpc_channel_args *channel_args, grpc_endpoint *ep, gpr_slice *slices, + size_t nslices, grpc_mdctx *mdctx, int is_client) { grpc_chttp2_transport *t = gpr_malloc(sizeof(grpc_chttp2_transport)); - init_transport(t, setup, arg, channel_args, ep, slices, nslices, mdctx, - is_client); + init_transport(t, channel_args, ep, slices, nslices, mdctx, is_client); + return &t->base; } diff --git a/src/core/transport/chttp2_transport.h b/src/core/transport/chttp2_transport.h index 18e19f03afe..1747792b95e 100644 --- a/src/core/transport/chttp2_transport.h +++ b/src/core/transport/chttp2_transport.h @@ -40,11 +40,8 @@ extern int grpc_http_trace; extern int grpc_flowctl_trace; -void grpc_create_chttp2_transport(grpc_transport_setup_callback setup, - void *arg, - const grpc_channel_args *channel_args, - grpc_endpoint *ep, gpr_slice *slices, - size_t nslices, grpc_mdctx *metadata_context, - int is_client); +grpc_transport *grpc_create_chttp2_transport( + const grpc_channel_args *channel_args, grpc_endpoint *ep, gpr_slice *slices, + size_t nslices, grpc_mdctx *metadata_context, int is_client); #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H */ diff --git a/src/core/transport/transport.c b/src/core/transport/transport.c index a570cba33e8..c29217599e0 100644 --- a/src/core/transport/transport.c +++ b/src/core/transport/transport.c @@ -64,24 +64,6 @@ void grpc_transport_destroy_stream(grpc_transport *transport, transport->vtable->destroy_stream(transport, stream); } -void grpc_transport_setup_cancel(grpc_transport_setup *setup) { - setup->vtable->cancel(setup); -} - -void grpc_transport_setup_initiate(grpc_transport_setup *setup) { - setup->vtable->initiate(setup); -} - -void grpc_transport_setup_add_interested_party(grpc_transport_setup *setup, - grpc_pollset *pollset) { - setup->vtable->add_interested_party(setup, pollset); -} - -void grpc_transport_setup_del_interested_party(grpc_transport_setup *setup, - grpc_pollset *pollset) { - setup->vtable->del_interested_party(setup, pollset); -} - void grpc_transport_stream_op_finish_with_failure( grpc_transport_stream_op *op) { if (op->send_ops) { diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h index 1acd665a1df..24a02132e95 100644 --- a/src/core/transport/transport.h +++ b/src/core/transport/transport.h @@ -174,51 +174,4 @@ void grpc_transport_close(grpc_transport *transport); /* Destroy the transport */ void grpc_transport_destroy(grpc_transport *transport); -/* Return type for grpc_transport_setup_callback */ -typedef struct grpc_transport_setup_result { - void *user_data; -} grpc_transport_setup_result; - -/* Given a transport, return callbacks for that transport. Used to finalize - setup as a transport is being created */ -typedef grpc_transport_setup_result (*grpc_transport_setup_callback)( - void *setup_arg, grpc_transport *transport, grpc_mdctx *mdctx); - -typedef struct grpc_transport_setup grpc_transport_setup; -typedef struct grpc_transport_setup_vtable grpc_transport_setup_vtable; - -struct grpc_transport_setup_vtable { - void (*initiate)(grpc_transport_setup *setup); - void (*add_interested_party)(grpc_transport_setup *setup, - grpc_pollset *pollset); - void (*del_interested_party)(grpc_transport_setup *setup, - grpc_pollset *pollset); - void (*cancel)(grpc_transport_setup *setup); -}; - -/* Transport setup is an asynchronous utility interface for client channels to - establish connections. It's transport agnostic. */ -struct grpc_transport_setup { - const grpc_transport_setup_vtable *vtable; -}; - -/* Initiate transport setup: e.g. for TCP+DNS trigger a resolve of the name - given at transport construction time, create the tcp connection, perform - handshakes, and call some grpc_transport_setup_result function provided at - setup construction time. - This *may* be implemented as a no-op if the setup process monitors something - continuously. */ -void grpc_transport_setup_initiate(grpc_transport_setup *setup); - -void grpc_transport_setup_add_interested_party(grpc_transport_setup *setup, - grpc_pollset *pollset); -void grpc_transport_setup_del_interested_party(grpc_transport_setup *setup, - grpc_pollset *pollset); - -/* Cancel transport setup. After this returns, no new transports should be - created, and all pending transport setup callbacks should be completed. - After this call completes, setup should be considered invalid (this can be - used as a destruction call by setup). */ -void grpc_transport_setup_cancel(grpc_transport_setup *setup); - #endif /* GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_H */ diff --git a/src/core/transport/transport_impl.h b/src/core/transport/transport_impl.h index 82839390502..b18f9570095 100644 --- a/src/core/transport/transport_impl.h +++ b/src/core/transport/transport_impl.h @@ -51,8 +51,7 @@ typedef struct grpc_transport_vtable { grpc_transport_stream_op *op); /* implementation of grpc_transport_perform_op */ - void (*perform_op)(grpc_transport *self, grpc_stream *stream, - grpc_transport_op *op); + void (*perform_op)(grpc_transport *self, grpc_transport_op *op); /* implementation of grpc_transport_destroy_stream */ void (*destroy_stream)(grpc_transport *self, grpc_stream *stream); From 7c0b4d70fcfd2a06b3ac5499bdb694b736f353dd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 14:44:44 -0700 Subject: [PATCH 037/124] Implement vtable helper stubs --- src/core/client_config/client_config.c | 40 ++++++++++++++++++++++++++ src/core/client_config/lb_policy.c | 17 +++++++++++ src/core/client_config/lb_policy.h | 4 +++ src/core/client_config/resolver.c | 25 ++++++++++++++++ src/core/client_config/resolver.h | 3 +- 5 files changed, 88 insertions(+), 1 deletion(-) diff --git a/src/core/client_config/client_config.c b/src/core/client_config/client_config.c index f462e54b4eb..e7d7647b882 100644 --- a/src/core/client_config/client_config.c +++ b/src/core/client_config/client_config.c @@ -32,3 +32,43 @@ */ #include "src/core/client_config/client_config.h" + +#include + +#include + +struct grpc_client_config { + gpr_refcount refs; + grpc_lb_policy *lb_policy; +}; + +grpc_client_config *grpc_client_config_create() { + grpc_client_config *c = gpr_malloc(sizeof(*c)); + memset(c, 0, sizeof(*c)); + gpr_ref_init(&c->refs, 1); + return c; +} + +void grpc_client_config_ref(grpc_client_config *c) { gpr_ref(&c->refs); } + +void grpc_client_config_unref(grpc_client_config *c) { + if (gpr_unref(&c->refs)) { + grpc_lb_policy_unref(c->lb_policy); + gpr_free(c); + } +} + +void grpc_client_config_set_lb_policy(grpc_client_config *c, + grpc_lb_policy *lb_policy) { + if (lb_policy) { + grpc_lb_policy_ref(c->lb_policy); + } + if (c->lb_policy) { + grpc_lb_policy_unref(c->lb_policy); + } + c->lb_policy = lb_policy; +} + +grpc_lb_policy *grpc_client_config_get_lb_policy(grpc_client_config *c) { + return c->lb_policy; +} diff --git a/src/core/client_config/lb_policy.c b/src/core/client_config/lb_policy.c index d8be4650cd9..5a2b70b94e0 100644 --- a/src/core/client_config/lb_policy.c +++ b/src/core/client_config/lb_policy.c @@ -32,3 +32,20 @@ */ #include "src/core/client_config/lb_policy.h" + +void grpc_lb_policy_ref(grpc_lb_policy *policy) { policy->vtable->ref(policy); } + +void grpc_lb_policy_unref(grpc_lb_policy *policy) { + policy->vtable->unref(policy); +} + +void grpc_lb_policy_shutdown(grpc_lb_policy *policy) { + policy->vtable->shutdown(policy); +} + +void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset, + grpc_metadata_batch *initial_metadata, + grpc_subchannel **target, + grpc_iomgr_closure *on_complete) { + policy->vtable->pick(policy, pollset, initial_metadata, target, on_complete); +} diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 0b21af4f699..4e185d90862 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -44,6 +44,10 @@ typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable; typedef void (*grpc_lb_completion)(void *cb_arg, grpc_subchannel *subchannel, grpc_status_code status, const char *errmsg); +struct grpc_lb_policy { + grpc_lb_policy_vtable *vtable; +}; + struct grpc_lb_policy_vtable { void (*ref)(grpc_lb_policy *policy); void (*unref)(grpc_lb_policy *policy); diff --git a/src/core/client_config/resolver.c b/src/core/client_config/resolver.c index 730ec317492..11ba27e58d8 100644 --- a/src/core/client_config/resolver.c +++ b/src/core/client_config/resolver.c @@ -32,3 +32,28 @@ */ #include "src/core/client_config/resolver.h" + +void grpc_resolver_ref(grpc_resolver *resolver) { + resolver->vtable->ref(resolver); +} + +void grpc_resolver_unref(grpc_resolver *resolver) { + resolver->vtable->unref(resolver); +} + +void grpc_resolver_shutdown(grpc_resolver *resolver) { + resolver->vtable->shutdown(resolver); +} + +void grpc_resolver_channel_saw_error(grpc_resolver *resolver, + struct sockaddr *failing_address, + int failing_address_len) { + resolver->vtable->channel_saw_error(resolver, failing_address, + failing_address_len); +} + +void grpc_resolver_next(grpc_resolver *resolver, + grpc_client_config **target_config, + grpc_iomgr_closure *on_complete) { + resolver->vtable->next(resolver, target_config, on_complete); +} diff --git a/src/core/client_config/resolver.h b/src/core/client_config/resolver.h index 13d48bc5721..7776870c083 100644 --- a/src/core/client_config/resolver.h +++ b/src/core/client_config/resolver.h @@ -65,7 +65,8 @@ void grpc_resolver_shutdown(grpc_resolver *resolver); /** Notification that the channel has seen an error on some address. Can be used as a hint that re-resolution is desirable soon. */ void grpc_resolver_channel_saw_error(grpc_resolver *resolver, - struct sockaddr *failing_address); + struct sockaddr *failing_address, + int failing_address_len); /** Get the next client config. Called by the channel to fetch a new configuration. Expected to set *target_config with a new configuration, From 2595ab7d96ce530e1ee1b1ed3d25311f18b1ca83 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 15:26:00 -0700 Subject: [PATCH 038/124] Refine subprocess_call API --- src/core/client_config/subchannel.c | 48 +++++++++++++++++++++++++++++ src/core/client_config/subchannel.h | 10 +++--- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index dfaa4f6405f..e268949be35 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -32,3 +32,51 @@ */ #include "src/core/client_config/subchannel.h" + +#include + +struct grpc_subchannel { + gpr_refcount refs; +}; + +struct grpc_subchannel_call { + grpc_subchannel *subchannel; + gpr_refcount refs; +}; + +#define SUBCHANNEL_CALL_TO_CALL_STACK(call) (((grpc_call_stack *)(call)) + 1) + +/* + * grpc_subchannel implementation + */ + +void grpc_subchannel_ref(grpc_subchannel *channel) { gpr_ref(&channel->refs); } + +void grpc_subchannel_unref(grpc_subchannel *channel) { + if (gpr_unref(&channel->refs)) { + gpr_free(channel); + } +} + +/* + * grpc_subchannel_call implementation + */ + +void grpc_subchannel_call_ref(grpc_subchannel_call *call) { + gpr_ref(&call->refs); +} + +void grpc_subchannel_call_unref(grpc_subchannel_call *call) { + if (gpr_unref(&call->refs)) { + grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(call)); + grpc_subchannel_unref(call->subchannel); + gpr_free(call); + } +} + +void grpc_subchannel_call_process_op(grpc_subchannel_call *call, + grpc_transport_stream_op *op) { + grpc_call_stack *call_stack = SUBCHANNEL_CALL_TO_CALL_STACK(call); + grpc_call_element *top_elem = grpc_call_stack_element(call_stack, 0); + top_elem->filter->start_transport_stream_op(top_elem, op); +} diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 0c6c9b3e64d..4d2efef7fbd 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -60,10 +60,12 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, grpc_connectivity_state *state, grpc_iomgr_closure *notify); -/** construct a call */ -grpc_subchannel_call *grpc_subchannel_create_call( - grpc_subchannel *subchannel, grpc_call_element *parent, - grpc_transport_stream_op *initial_op); +/** construct a call (asynchronously) */ +void grpc_subchannel_create_call(grpc_subchannel *subchannel, + grpc_call_element *parent, + grpc_transport_stream_op *initial_op, + grpc_subchannel_call **target, + grpc_iomgr_closure *notify); /** continue processing a transport op */ void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, From 916246625bad68c6ea63d5a2cfca644a7e01cfe1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 25 Jun 2015 16:31:02 -0700 Subject: [PATCH 039/124] Introduce connector, to help subchannel connect --- BUILD | 4 ++ Makefile | 2 + build.json | 2 + gRPC.podspec | 3 + src/core/channel/channel_args.h | 2 + src/core/client_config/connector.c | 35 ++++++++++++ src/core/client_config/connector.h | 56 +++++++++++++++++++ src/core/client_config/subchannel.c | 1 + src/core/client_config/subchannel.h | 9 +-- src/core/surface/channel_create.c | 53 +++++++++++++++++- tools/doxygen/Doxyfile.core.internal | 2 + vsprojects/grpc/grpc.vcxproj | 3 + vsprojects/grpc/grpc.vcxproj.filters | 6 ++ .../grpc_unsecure/grpc_unsecure.vcxproj | 3 + .../grpc_unsecure.vcxproj.filters | 6 ++ 15 files changed, 181 insertions(+), 6 deletions(-) create mode 100644 src/core/client_config/connector.c create mode 100644 src/core/client_config/connector.h diff --git a/BUILD b/BUILD index 29cc77374e4..e6087a0fd74 100644 --- a/BUILD +++ b/BUILD @@ -157,6 +157,7 @@ cc_library( "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", "src/core/client_config/client_config.h", + "src/core/client_config/connector.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policy.h", "src/core/client_config/resolver.h", @@ -271,6 +272,7 @@ cc_library( "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", "src/core/client_config/client_config.c", + "src/core/client_config/connector.c", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policy.c", "src/core/client_config/resolver.c", @@ -403,6 +405,7 @@ cc_library( "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", "src/core/client_config/client_config.h", + "src/core/client_config/connector.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policy.h", "src/core/client_config/resolver.h", @@ -495,6 +498,7 @@ cc_library( "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", "src/core/client_config/client_config.c", + "src/core/client_config/connector.c", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policy.c", "src/core/client_config/resolver.c", diff --git a/Makefile b/Makefile index 7ca182d9de6..a58ef8f7e6c 100644 --- a/Makefile +++ b/Makefile @@ -3022,6 +3022,7 @@ LIBGRPC_SRC = \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ src/core/client_config/client_config.c \ + src/core/client_config/connector.c \ src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policy.c \ src/core/client_config/resolver.c \ @@ -3279,6 +3280,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ src/core/client_config/client_config.c \ + src/core/client_config/connector.c \ src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policy.c \ src/core/client_config/resolver.c \ diff --git a/build.json b/build.json index dc3d2ac1c57..5534843c894 100644 --- a/build.json +++ b/build.json @@ -118,6 +118,7 @@ "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", "src/core/client_config/client_config.h", + "src/core/client_config/connector.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policy.h", "src/core/client_config/resolver.h", @@ -210,6 +211,7 @@ "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", "src/core/client_config/client_config.c", + "src/core/client_config/connector.c", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policy.c", "src/core/client_config/resolver.c", diff --git a/gRPC.podspec b/gRPC.podspec index 1707ee7eaac..862c24b27e7 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -159,6 +159,7 @@ Pod::Spec.new do |s| 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', + 'src/core/client_config/connector.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', @@ -280,6 +281,7 @@ Pod::Spec.new do |s| 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', 'src/core/client_config/client_config.c', + 'src/core/client_config/connector.c', 'src/core/client_config/lb_policies/pick_first.c', 'src/core/client_config/lb_policy.c', 'src/core/client_config/resolver.c', @@ -411,6 +413,7 @@ Pod::Spec.new do |s| 'src/core/channel/http_server_filter.h', 'src/core/channel/noop_filter.h', 'src/core/client_config/client_config.h', + 'src/core/client_config/connector.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policy.h', 'src/core/client_config/resolver.h', diff --git a/src/core/channel/channel_args.h b/src/core/channel/channel_args.h index bf747b26e64..41f3a554d6c 100644 --- a/src/core/channel/channel_args.h +++ b/src/core/channel/channel_args.h @@ -45,6 +45,8 @@ grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src); grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src, const grpc_arg *to_add); +grpc_channel_args *grpc_channel_args_merge(const grpc_channel_args *a, const grpc_channel_args *b); + /** Destroy arguments created by grpc_channel_args_copy */ void grpc_channel_args_destroy(grpc_channel_args *a); diff --git a/src/core/client_config/connector.c b/src/core/client_config/connector.c new file mode 100644 index 00000000000..c9115ac93a6 --- /dev/null +++ b/src/core/client_config/connector.c @@ -0,0 +1,35 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/connector.h" + diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h new file mode 100644 index 00000000000..09854327617 --- /dev/null +++ b/src/core/client_config/connector.h @@ -0,0 +1,56 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H + +#include "src/core/transport/transport.h" + +typedef struct grpc_connector grpc_connector; +typedef struct grpc_connector_vtable grpc_connector_vtable; + +struct grpc_connector { + const grpc_connector_vtable *vtable; +}; + +struct grpc_connector_vtable { + void (*ref)(grpc_connector *connector); + void (*unref)(grpc_connector *connector); + void (*connect)(grpc_connector *connector, const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, grpc_transport **transport, grpc_iomgr_closure *notify); +}; + +void grpc_connector_ref(grpc_connector *connector); +void grpc_connector_unref(grpc_connector *connector); +void grpc_connector_connect(grpc_connector *connector, const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, grpc_transport **transport, grpc_iomgr_closure *notify); + +#endif diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index e268949be35..588c63cdd32 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -37,6 +37,7 @@ struct grpc_subchannel { gpr_refcount refs; + grpc_connector *connector; }; struct grpc_subchannel_call { diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 4d2efef7fbd..ab241238540 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -35,9 +35,7 @@ #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H #include "src/core/channel/channel_stack.h" -#include "src/core/iomgr/iomgr.h" -#include "src/core/iomgr/sockaddr.h" -#include "src/core/transport/transport.h" +#include "src/core/client_config/connector.h" /** A (sub-)channel that knows how to connect to exactly one target address. Provides a target for load balancing. */ @@ -60,7 +58,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, grpc_connectivity_state *state, grpc_iomgr_closure *notify); -/** construct a call (asynchronously) */ +/** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, grpc_call_element *parent, grpc_transport_stream_op *initial_op, @@ -71,4 +69,7 @@ void grpc_subchannel_create_call(grpc_subchannel *subchannel, void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, grpc_transport_stream_op *op); +/** create a subchannel given a connector */ +grpc_subchannel *grpc_subchannel_create(grpc_connector *connector); + #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H */ diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 14ff63a2e38..2d63d7e7662 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -36,10 +36,55 @@ #include #include +#include + +#include "src/core/channel/channel_args.h" #include "src/core/channel/client_channel.h" #include "src/core/client_config/resolver_registry.h" #include "src/core/surface/channel.h" +typedef struct { + grpc_connector base; + gpr_refcount refs; + struct sockaddr *addr; + int addr_len; + grpc_channel_args *args; +} connector; + +typedef struct { + grpc_subchannel_factory base; + gpr_refcount refs; + grpc_channel_args *args; +} subchannel_factory; + +static void subchannel_factory_ref(grpc_subchannel_factory *scf) { + subchannel_factory *f = (subchannel_factory*)scf; + gpr_ref(&f->refs); +} + +static void subchannel_factory_unref(grpc_subchannel_factory *scf) { + subchannel_factory *f = (subchannel_factory*)scf; + if (gpr_unref(&f->refs)) { + grpc_channel_args_destroy(f->args); + gpr_free(f); + } +} + +static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { + subchannel_factory *f = (subchannel_factory*)scf; + connector *c = gpr_malloc(sizeof(*c)); + c->base.vtable = &connector_vtable; + gpr_ref_init(&c->refs, 1); + c->addr = gpr_malloc(args->addr_len); + memcpy(c->addr, args->addr, args->addr_len); + c->addr_len = args->addr_len; + c->args = grpc_channel_args_merge(args->args, f->args); + + return grpc_subchannel_create(&c->base); +} + +static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchannel_factory_ref, subchannel_factory_unref, subchannel_factory_create_subchannel}; + /* Create a client channel: Asynchronously: - resolve target - connect to it (trying alternatives as presented) @@ -47,6 +92,7 @@ grpc_channel *grpc_channel_create(const char *target, const grpc_channel_args *args) { grpc_channel *channel = NULL; + subchannel_factory *scfactory = gpr_malloc(sizeof(*scfactory)); #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; grpc_resolver *resolver; @@ -58,8 +104,11 @@ grpc_channel *grpc_channel_create(const char *target, filters[n++] = &grpc_client_channel_filter; GPR_ASSERT(n <= MAX_FILTERS); - GPR_ASSERT(!"NULL should be a subchannel factory creation below"); - resolver = grpc_resolver_create(target, NULL); + scfactory->base.vtable = &subchannel_factory_vtable; + gpr_ref_init(&scfactory->refs, 1); + scfactory->args = grpc_channel_args_copy(args); + + resolver = grpc_resolver_create(target, &scfactory->base); if (!resolver) { return NULL; } diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index bc2cfaf6a47..56af4ce3126 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -794,6 +794,7 @@ src/core/channel/http_client_filter.h \ src/core/channel/http_server_filter.h \ src/core/channel/noop_filter.h \ src/core/client_config/client_config.h \ +src/core/client_config/connector.h \ src/core/client_config/lb_policies/pick_first.h \ src/core/client_config/lb_policy.h \ src/core/client_config/resolver.h \ @@ -908,6 +909,7 @@ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ src/core/client_config/client_config.c \ +src/core/client_config/connector.c \ src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policy.c \ src/core/client_config/resolver.c \ diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 6c55c4f8341..854443935b8 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -183,6 +183,7 @@ + @@ -331,6 +332,8 @@ + + diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index d2ada43b6db..2c02e4a0d85 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -97,6 +97,9 @@ src\core\client_config + + src\core\client_config + src\core\client_config\lb_policies @@ -494,6 +497,9 @@ src\core\client_config + + src\core\client_config + src\core\client_config\lb_policies diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index 09b39972779..9080bffff95 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -165,6 +165,7 @@ + @@ -269,6 +270,8 @@ + + diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index 3b65c46f2b1..3861eef863b 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -31,6 +31,9 @@ src\core\client_config + + src\core\client_config + src\core\client_config\lb_policies @@ -377,6 +380,9 @@ src\core\client_config + + src\core\client_config + src\core\client_config\lb_policies From f7afa1f1ba4953c7bd6d20f0bbabc5742d3faea8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 26 Jun 2015 09:02:20 -0700 Subject: [PATCH 040/124] client_config: chttp2_fullstack_no_op_unsecure_test passes --- src/core/client_config/connector.c | 16 +++++++ src/core/client_config/connector.h | 11 ++++- src/core/client_config/resolver_factory.c | 15 ++++++ src/core/client_config/subchannel.c | 28 +++++++++++ src/core/client_config/subchannel.h | 17 ++++++- src/core/client_config/subchannel_factory.h | 14 ------ src/core/surface/channel_create.c | 53 +++++++++------------ 7 files changed, 107 insertions(+), 47 deletions(-) diff --git a/src/core/client_config/connector.c b/src/core/client_config/connector.c index c9115ac93a6..c3a8962ea66 100644 --- a/src/core/client_config/connector.c +++ b/src/core/client_config/connector.c @@ -33,3 +33,19 @@ #include "src/core/client_config/connector.h" +void grpc_connector_ref(grpc_connector *connector) { + connector->vtable->ref(connector); +} + +void grpc_connector_unref(grpc_connector *connector) { + connector->vtable->unref(connector); +} + +void grpc_connector_connect(grpc_connector *connector, + const grpc_channel_args *channel_args, + grpc_mdctx *metadata_context, + grpc_transport **transport, + grpc_iomgr_closure *notify) { + connector->vtable->connect(connector, channel_args, metadata_context, + transport, notify); +} diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h index 09854327617..8ada75ec708 100644 --- a/src/core/client_config/connector.h +++ b/src/core/client_config/connector.h @@ -46,11 +46,18 @@ struct grpc_connector { struct grpc_connector_vtable { void (*ref)(grpc_connector *connector); void (*unref)(grpc_connector *connector); - void (*connect)(grpc_connector *connector, const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, grpc_transport **transport, grpc_iomgr_closure *notify); + void (*connect)(grpc_connector *connector, + const grpc_channel_args *channel_args, + grpc_mdctx *metadata_context, grpc_transport **transport, + grpc_iomgr_closure *notify); }; void grpc_connector_ref(grpc_connector *connector); void grpc_connector_unref(grpc_connector *connector); -void grpc_connector_connect(grpc_connector *connector, const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, grpc_transport **transport, grpc_iomgr_closure *notify); +void grpc_connector_connect(grpc_connector *connector, + const grpc_channel_args *channel_args, + grpc_mdctx *metadata_context, + grpc_transport **transport, + grpc_iomgr_closure *notify); #endif diff --git a/src/core/client_config/resolver_factory.c b/src/core/client_config/resolver_factory.c index 60ce65f554b..378529d5b21 100644 --- a/src/core/client_config/resolver_factory.c +++ b/src/core/client_config/resolver_factory.c @@ -32,3 +32,18 @@ */ #include "src/core/client_config/resolver_factory.h" + +void grpc_resolver_factory_ref(grpc_resolver_factory *factory) { + factory->vtable->ref(factory); +} + +void grpc_resolver_factory_unref(grpc_resolver_factory *factory) { + factory->vtable->unref(factory); +} + +/** Create a resolver instance for a name */ +grpc_resolver *grpc_resolver_factory_create_resolver( + grpc_resolver_factory *factory, grpc_uri *uri, + grpc_subchannel_factory *subchannel_factory) { + return factory->vtable->create_resolver(factory, uri, subchannel_factory); +} diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 588c63cdd32..037f0c0ab04 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -33,11 +33,22 @@ #include "src/core/client_config/subchannel.h" +#include + #include struct grpc_subchannel { gpr_refcount refs; grpc_connector *connector; + + /** non-transport related channel filters */ + const grpc_channel_filter **filters; + size_t filter_count; + /** channel arguments */ + grpc_channel_args *args; + /** address to connect to */ + struct sockaddr *addr; + size_t addr_len; }; struct grpc_subchannel_call { @@ -59,6 +70,23 @@ void grpc_subchannel_unref(grpc_subchannel *channel) { } } +grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, + grpc_subchannel_args *args) { + grpc_subchannel *c = gpr_malloc(sizeof(*c)); + memset(c, 0, sizeof(*c)); + gpr_ref_init(&c->refs, 1); + c->connector = connector; + grpc_connector_ref(c->connector); + c->filters = gpr_malloc(sizeof(grpc_channel_filter *) * args->filter_count); + memcpy(c->filters, args->filters, + sizeof(grpc_channel_filter *) * args->filter_count); + c->filter_count = args->filter_count; + c->addr = gpr_malloc(args->addr_len); + memcpy(c->addr, args->addr, args->addr_len); + c->addr_len = args->addr_len; + return c; +} + /* * grpc_subchannel_call implementation */ diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index ab241238540..b4d40eadfa0 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -41,6 +41,7 @@ address. Provides a target for load balancing. */ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; +typedef struct grpc_subchannel_args grpc_subchannel_args; void grpc_subchannel_ref(grpc_subchannel *channel); void grpc_subchannel_unref(grpc_subchannel *channel); @@ -69,7 +70,21 @@ void grpc_subchannel_create_call(grpc_subchannel *subchannel, void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, grpc_transport_stream_op *op); +struct grpc_subchannel_args { + /** Channel filters for this channel - wrapped factories will likely + want to mutate this */ + const grpc_channel_filter **filters; + /** The number of filters in the above array */ + size_t filter_count; + /** Channel arguments to be supplied to the newly created channel */ + const grpc_channel_args *args; + /** Address to connect to */ + struct sockaddr *addr; + size_t addr_len; +}; + /** create a subchannel given a connector */ -grpc_subchannel *grpc_subchannel_create(grpc_connector *connector); +grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, + grpc_subchannel_args *args); #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H */ diff --git a/src/core/client_config/subchannel_factory.h b/src/core/client_config/subchannel_factory.h index cbe984f428a..d7eae1c9646 100644 --- a/src/core/client_config/subchannel_factory.h +++ b/src/core/client_config/subchannel_factory.h @@ -39,7 +39,6 @@ typedef struct grpc_subchannel_factory grpc_subchannel_factory; typedef struct grpc_subchannel_factory_vtable grpc_subchannel_factory_vtable; -typedef struct grpc_subchannel_args grpc_subchannel_args; /** Constructor for new configured channels. Creating decorators around this type is encouraged to adapt behavior. */ @@ -47,19 +46,6 @@ struct grpc_subchannel_factory { const grpc_subchannel_factory_vtable *vtable; }; -struct grpc_subchannel_args { - /** Channel filters for this channel - wrapped factories will likely - want to mutate this */ - const grpc_channel_filter **filters; - /** The number of filters in the above array */ - size_t filter_count; - /** Channel arguments to be supplied to the newly created channel */ - const grpc_channel_args *args; - /** Address to connect to */ - struct sockaddr *addr; - size_t addr_len; -}; - struct grpc_subchannel_factory_vtable { void (*ref)(grpc_subchannel_factory *factory); void (*unref)(grpc_subchannel_factory *factory); diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 2d63d7e7662..ba4e1a24ecc 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -46,44 +46,42 @@ typedef struct { grpc_connector base; gpr_refcount refs; - struct sockaddr *addr; - int addr_len; - grpc_channel_args *args; } connector; -typedef struct { - grpc_subchannel_factory base; - gpr_refcount refs; - grpc_channel_args *args; -} subchannel_factory; - -static void subchannel_factory_ref(grpc_subchannel_factory *scf) { - subchannel_factory *f = (subchannel_factory*)scf; - gpr_ref(&f->refs); +static void connector_ref(grpc_connector *con) { + connector *c = (connector *)con; + gpr_ref(&c->refs); } -static void subchannel_factory_unref(grpc_subchannel_factory *scf) { - subchannel_factory *f = (subchannel_factory*)scf; - if (gpr_unref(&f->refs)) { - grpc_channel_args_destroy(f->args); - gpr_free(f); +static void connector_unref(grpc_connector *con) { + connector *c = (connector *)con; + if (gpr_unref(&c->refs)) { + gpr_free(c); } } +static void connector_connect(grpc_connector *connector, const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, grpc_transport **transport, grpc_iomgr_closure *notify) { + abort(); +} + +static const grpc_connector_vtable connector_vtable = {connector_ref, connector_unref, connector_connect}; + +static void subchannel_factory_ref(grpc_subchannel_factory *scf) {} + +static void subchannel_factory_unref(grpc_subchannel_factory *scf) {} + static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { - subchannel_factory *f = (subchannel_factory*)scf; connector *c = gpr_malloc(sizeof(*c)); + grpc_subchannel *s; c->base.vtable = &connector_vtable; gpr_ref_init(&c->refs, 1); - c->addr = gpr_malloc(args->addr_len); - memcpy(c->addr, args->addr, args->addr_len); - c->addr_len = args->addr_len; - c->args = grpc_channel_args_merge(args->args, f->args); - - return grpc_subchannel_create(&c->base); + s = grpc_subchannel_create(&c->base, args); + grpc_connector_unref(&c->base); + return s; } static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchannel_factory_ref, subchannel_factory_unref, subchannel_factory_create_subchannel}; +static grpc_subchannel_factory subchannel_factory = {&subchannel_factory_vtable}; /* Create a client channel: Asynchronously: - resolve target @@ -92,7 +90,6 @@ static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchan grpc_channel *grpc_channel_create(const char *target, const grpc_channel_args *args) { grpc_channel *channel = NULL; - subchannel_factory *scfactory = gpr_malloc(sizeof(*scfactory)); #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; grpc_resolver *resolver; @@ -104,11 +101,7 @@ grpc_channel *grpc_channel_create(const char *target, filters[n++] = &grpc_client_channel_filter; GPR_ASSERT(n <= MAX_FILTERS); - scfactory->base.vtable = &subchannel_factory_vtable; - gpr_ref_init(&scfactory->refs, 1); - scfactory->args = grpc_channel_args_copy(args); - - resolver = grpc_resolver_create(target, &scfactory->base); + resolver = grpc_resolver_create(target, &subchannel_factory); if (!resolver) { return NULL; } From eb3b12e41752acbde3c020af3cebbdd6baf97e60 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 26 Jun 2015 14:42:49 -0700 Subject: [PATCH 041/124] Further client config work --- src/core/channel/client_channel.c | 329 +++++++++--------- src/core/client_config/client_config.c | 2 +- .../client_config/lb_policies/pick_first.c | 169 +++++++++ src/core/client_config/lb_policy.h | 2 +- src/core/client_config/resolver_factory.c | 1 + src/core/client_config/resolver_registry.c | 79 +++-- src/core/client_config/resolver_registry.h | 12 +- .../client_config/resolvers/dns_resolver.c | 47 +-- .../client_config/resolvers/dns_resolver.h | 3 +- src/core/client_config/subchannel.c | 77 +++- src/core/client_config/subchannel.h | 5 +- src/core/client_config/subchannel_factory.c | 12 + src/core/client_config/uri_parser.c | 25 +- src/core/client_config/uri_parser.h | 3 - src/core/surface/init.c | 4 + test/core/end2end/fixtures/chttp2_fullstack.c | 1 + 16 files changed, 511 insertions(+), 260 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 9630f6898d8..965d4e53dc6 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -34,6 +34,7 @@ #include "src/core/channel/client_channel.h" #include +#include #include "src/core/channel/channel_args.h" #include "src/core/channel/connected_channel.h" @@ -75,6 +76,7 @@ typedef enum { CALL_CREATED, CALL_WAITING_FOR_CONFIG, CALL_WAITING_FOR_PICK, + CALL_WAITING_FOR_CALL, CALL_ACTIVE, CALL_CANCELLED } call_state; @@ -87,17 +89,13 @@ struct call_data { call_state state; gpr_timespec deadline; - union { - struct { - /* our child call stack */ - grpc_subchannel_call *subchannel_call; - } active; - grpc_transport_stream_op waiting_op; - struct { - grpc_linked_mdelem status; - grpc_linked_mdelem details; - } cancelled; - } s; + grpc_subchannel *picked_channel; + grpc_iomgr_closure async_setup_task; + grpc_transport_stream_op waiting_op; + /* our child call stack */ + grpc_subchannel_call *subchannel_call; + grpc_linked_mdelem status; + grpc_linked_mdelem details; }; #if 0 @@ -110,9 +108,9 @@ static int prepare_activate(grpc_call_element *elem, /* no more access to calld->s.waiting allowed */ GPR_ASSERT(calld->state == CALL_WAITING); - if (calld->s.waiting_op.bind_pollset) { + if (calld->waiting_op.bind_pollset) { grpc_transport_setup_del_interested_party(chand->transport_setup, - calld->s.waiting_op.bind_pollset); + calld->waiting_op.bind_pollset); } calld->state = CALL_ACTIVE; @@ -143,7 +141,7 @@ static void remove_waiting_child(channel_data *chand, call_data *calld) { for (i = 0, new_count = 0; i < chand->waiting_child_count; i++) { if (chand->waiting_children[i] == calld) { grpc_transport_setup_del_interested_party( - chand->transport_setup, calld->s.waiting_op.bind_pollset); + chand->transport_setup, calld->waiting_op.bind_pollset); continue; } chand->waiting_children[new_count++] = chand->waiting_children[i]; @@ -166,15 +164,15 @@ static void handle_op_after_cancellation(grpc_call_element *elem, char status[GPR_LTOA_MIN_BUFSIZE]; grpc_metadata_batch mdb; gpr_ltoa(GRPC_STATUS_CANCELLED, status); - calld->s.cancelled.status.md = + calld->status.md = grpc_mdelem_from_strings(chand->mdctx, "grpc-status", status); - calld->s.cancelled.details.md = + calld->details.md = grpc_mdelem_from_strings(chand->mdctx, "grpc-message", "Cancelled"); - calld->s.cancelled.status.prev = calld->s.cancelled.details.next = NULL; - calld->s.cancelled.status.next = &calld->s.cancelled.details; - calld->s.cancelled.details.prev = &calld->s.cancelled.status; - mdb.list.head = &calld->s.cancelled.status; - mdb.list.tail = &calld->s.cancelled.details; + calld->status.prev = calld->details.next = NULL; + calld->status.next = &calld->details; + calld->details.prev = &calld->status; + mdb.list.head = &calld->status; + mdb.list.tail = &calld->details; mdb.garbage.head = mdb.garbage.tail = NULL; mdb.deadline = gpr_inf_future; grpc_sopb_add_metadata(op->recv_ops, mdb); @@ -186,16 +184,111 @@ static void handle_op_after_cancellation(grpc_call_element *elem, } } -static void add_to_lb_policy_wait_queue_locked_state_config(channel_data *chand, call_data *calld) { - abort(); +typedef struct { + grpc_iomgr_closure closure; + grpc_call_element *elem; +} waiting_call; + +static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_stream_op *op, int continuation); + +static void continue_with_pick(void *arg, int iomgr_success) { + waiting_call *wc = arg; + call_data *calld = wc->elem->call_data; + perform_transport_stream_op(wc->elem, &calld->waiting_op, 1); + gpr_free(wc); +} + +static void add_to_lb_policy_wait_queue_locked_state_config(grpc_call_element *elem) { + channel_data *chand = elem->channel_data; + waiting_call *wc = gpr_malloc(sizeof(*wc)); + grpc_iomgr_closure_init(&wc->closure, continue_with_pick, wc); + wc->elem = elem; + wc->closure.next = chand->waiting_for_config_closures; + chand->waiting_for_config_closures = &wc->closure; +} + +static int is_empty(void *p, int len) { + char *ptr = p; + int i; + for (i = 0; i < len; i++) { + if (ptr[i] != 0) return 0; + } + return 1; +} + +static void started_call(void *arg, int iomgr_success) { + call_data *calld = arg; + grpc_transport_stream_op op; + int have_waiting; + + gpr_mu_lock(&calld->mu_state); + if (calld->state == CALL_CANCELLED && calld->subchannel_call != NULL) { + memset(&op, 0, sizeof(op)); + op.cancel_with_status = GRPC_STATUS_CANCELLED; + gpr_mu_unlock(&calld->mu_state); + grpc_subchannel_call_process_op(calld->subchannel_call, &op); + } else if (calld->state == CALL_WAITING_FOR_CALL) { + have_waiting = !is_empty(&calld->waiting_op, sizeof(calld->waiting_op)); + if (calld->subchannel_call != NULL) { + calld->state = CALL_ACTIVE; + gpr_mu_unlock(&calld->mu_state); + if (have_waiting) { + grpc_subchannel_call_process_op(calld->subchannel_call, &calld->waiting_op); + } + } else { + calld->state = CALL_CANCELLED; + gpr_mu_unlock(&calld->mu_state); + if (have_waiting) { + handle_op_after_cancellation(calld->elem, &calld->waiting_op); + } + } + } else { + GPR_ASSERT(calld->state == CALL_CANCELLED); + } +} + +static void picked_target(void *arg, int iomgr_success) { + call_data *calld = arg; + channel_data *chand = calld->elem->channel_data; + grpc_transport_stream_op op; + + if (calld->picked_channel == NULL) { + /* treat this like a cancellation */ + calld->waiting_op.cancel_with_status = GRPC_STATUS_UNAVAILABLE; + perform_transport_stream_op(calld->elem, &calld->waiting_op, 1); + } else { + gpr_mu_lock(&calld->mu_state); + if (calld->state == CALL_CANCELLED) { + gpr_mu_unlock(&calld->mu_state); + handle_op_after_cancellation(calld->elem, &calld->waiting_op); + } else { + GPR_ASSERT(calld->state == CALL_WAITING_FOR_PICK); + calld->state = CALL_WAITING_FOR_CALL; + op = calld->waiting_op; + memset(&calld->waiting_op, 0, sizeof(calld->waiting_op)); + gpr_mu_unlock(&calld->mu_state); + grpc_iomgr_closure_init(&calld->async_setup_task, started_call, calld); + grpc_subchannel_create_call(calld->picked_channel, chand->mdctx, &op, &calld->subchannel_call, &calld->async_setup_task); + } + } } static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { - abort(); + grpc_metadata_batch *initial_metadata; + grpc_transport_stream_op *op = &calld->waiting_op; + + GPR_ASSERT(op->bind_pollset); + GPR_ASSERT(op->send_ops); + GPR_ASSERT(op->send_ops->nops >= 1); + GPR_ASSERT(op->send_ops->ops[0].type == GRPC_OP_METADATA); + initial_metadata = &op->send_ops->ops[0].data.metadata; + + grpc_iomgr_closure_init(&calld->async_setup_task, picked_target, calld); + grpc_lb_policy_pick(lb_policy, op->bind_pollset, + initial_metadata, &calld->picked_channel, &calld->async_setup_task); } -static void cc_start_transport_stream_op(grpc_call_element *elem, - grpc_transport_stream_op *op) { +static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_stream_op *op, int continuation) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; grpc_subchannel_call *subchannel_call; @@ -206,7 +299,8 @@ static void cc_start_transport_stream_op(grpc_call_element *elem, gpr_mu_lock(&calld->mu_state); switch (calld->state) { case CALL_ACTIVE: - subchannel_call = calld->s.active.subchannel_call; + GPR_ASSERT(!continuation); + subchannel_call = calld->subchannel_call; gpr_mu_unlock(&calld->mu_state); grpc_subchannel_call_process_op(subchannel_call, op); break; @@ -214,13 +308,44 @@ static void cc_start_transport_stream_op(grpc_call_element *elem, gpr_mu_unlock(&calld->mu_state); handle_op_after_cancellation(elem, op); break; + case CALL_WAITING_FOR_CONFIG: + case CALL_WAITING_FOR_PICK: + case CALL_WAITING_FOR_CALL: + if (!continuation) { + if (op->cancel_with_status != GRPC_STATUS_OK) { + calld->state = CALL_CANCELLED; + gpr_mu_unlock(&calld->mu_state); + handle_op_after_cancellation(elem, op); + } else { + GPR_ASSERT((calld->waiting_op.send_ops == NULL) != + (op->send_ops == NULL)); + GPR_ASSERT((calld->waiting_op.recv_ops == NULL) != + (op->recv_ops == NULL)); + if (op->send_ops != NULL) { + calld->waiting_op.send_ops = op->send_ops; + calld->waiting_op.is_last_send = op->is_last_send; + calld->waiting_op.on_done_send = op->on_done_send; + } + if (op->recv_ops != NULL) { + calld->waiting_op.recv_ops = op->recv_ops; + calld->waiting_op.recv_state = op->recv_state; + calld->waiting_op.on_done_recv = op->on_done_recv; + } + gpr_mu_unlock(&calld->mu_state); + if (op->on_consumed != NULL) { + op->on_consumed->cb(op->on_consumed->cb_arg, 0); + } + } + break; + } + /* fall through */ case CALL_CREATED: if (op->cancel_with_status != GRPC_STATUS_OK) { calld->state = CALL_CANCELLED; gpr_mu_unlock(&calld->mu_state); handle_op_after_cancellation(elem, op); } else { - calld->s.waiting_op = *op; + calld->waiting_op = *op; gpr_mu_lock(&chand->mu_config); lb_policy = chand->lb_policy; @@ -235,141 +360,22 @@ static void cc_start_transport_stream_op(grpc_call_element *elem, grpc_lb_policy_unref(lb_policy); } else { calld->state = CALL_WAITING_FOR_CONFIG; - add_to_lb_policy_wait_queue_locked_state_config(chand, calld); + add_to_lb_policy_wait_queue_locked_state_config(elem); gpr_mu_unlock(&chand->mu_config); gpr_mu_unlock(&calld->mu_state); } } break; - case CALL_WAITING_FOR_CONFIG: - case CALL_WAITING_FOR_PICK: - if (op->cancel_with_status != GRPC_STATUS_OK) { - calld->state = CALL_CANCELLED; - gpr_mu_unlock(&calld->mu_state); - handle_op_after_cancellation(elem, op); - } else { - GPR_ASSERT((calld->s.waiting_op.send_ops == NULL) != - (op->send_ops == NULL)); - GPR_ASSERT((calld->s.waiting_op.recv_ops == NULL) != - (op->recv_ops == NULL)); - if (op->send_ops != NULL) { - calld->s.waiting_op.send_ops = op->send_ops; - calld->s.waiting_op.is_last_send = op->is_last_send; - calld->s.waiting_op.on_done_send = op->on_done_send; - } - if (op->recv_ops != NULL) { - calld->s.waiting_op.recv_ops = op->recv_ops; - calld->s.waiting_op.recv_state = op->recv_state; - calld->s.waiting_op.on_done_recv = op->on_done_recv; - } - gpr_mu_unlock(&calld->mu_state); - if (op->on_consumed != NULL) { - op->on_consumed->cb(op->on_consumed->cb_arg, 0); - } - } - break; } +} - - - -#if 0 - gpr_mu_lock(&chand->mu); - switch (calld->state) { - case CALL_ACTIVE: - child_elem = grpc_child_call_get_top_element(calld->s.active.child_call); - gpr_mu_unlock(&chand->mu); - child_elem->filter->start_transport_op(child_elem, op); - break; - case CALL_CREATED: - if (op->cancel_with_status != GRPC_STATUS_OK) { - calld->state = CALL_CANCELLED; - gpr_mu_unlock(&chand->mu); - handle_op_after_cancellation(elem, op); - } else { - calld->state = CALL_WAITING; - calld->s.waiting_op.bind_pollset = NULL; - if (chand->active_child) { - /* channel is connected - use the connected stack */ - if (prepare_activate(elem, chand->active_child)) { - gpr_mu_unlock(&chand->mu); - /* activate the request (pass it down) outside the lock */ - complete_activate(elem, op); - } else { - gpr_mu_unlock(&chand->mu); - } - } else { - /* check to see if we should initiate a connection (if we're not - already), - but don't do so until outside the lock to avoid re-entrancy - problems if - the callback is immediate */ - int initiate_transport_setup = 0; - if (!chand->transport_setup_initiated) { - chand->transport_setup_initiated = 1; - initiate_transport_setup = 1; - } - /* add this call to the waiting set to be resumed once we have a child - channel stack, growing the waiting set if needed */ - if (chand->waiting_child_count == chand->waiting_child_capacity) { - chand->waiting_child_capacity = - GPR_MAX(chand->waiting_child_capacity * 2, 8); - chand->waiting_children = gpr_realloc( - chand->waiting_children, - chand->waiting_child_capacity * sizeof(call_data *)); - } - calld->s.waiting_op = *op; - chand->waiting_children[chand->waiting_child_count++] = calld; - grpc_transport_setup_add_interested_party(chand->transport_setup, - op->bind_pollset); - gpr_mu_unlock(&chand->mu); - - /* finally initiate transport setup if needed */ - if (initiate_transport_setup) { - grpc_transport_setup_initiate(chand->transport_setup); - } - } - } - break; - case CALL_WAITING: - if (op->cancel_with_status != GRPC_STATUS_OK) { - waiting_op = calld->s.waiting_op; - remove_waiting_child(chand, calld); - calld->state = CALL_CANCELLED; - gpr_mu_unlock(&chand->mu); - handle_op_after_cancellation(elem, &waiting_op); - handle_op_after_cancellation(elem, op); - } else { - GPR_ASSERT((calld->s.waiting_op.send_ops == NULL) != - (op->send_ops == NULL)); - GPR_ASSERT((calld->s.waiting_op.recv_ops == NULL) != - (op->recv_ops == NULL)); - if (op->send_ops) { - calld->s.waiting_op.send_ops = op->send_ops; - calld->s.waiting_op.is_last_send = op->is_last_send; - calld->s.waiting_op.on_done_send = op->on_done_send; - } - if (op->recv_ops) { - calld->s.waiting_op.recv_ops = op->recv_ops; - calld->s.waiting_op.recv_state = op->recv_state; - calld->s.waiting_op.on_done_recv = op->on_done_recv; - } - gpr_mu_unlock(&chand->mu); - if (op->on_consumed) { - op->on_consumed->cb(op->on_consumed->cb_arg, 0); - } - } - break; - case CALL_CANCELLED: - gpr_mu_unlock(&chand->mu); - handle_op_after_cancellation(elem, op); - break; - } -#endif +static void cc_start_transport_stream_op(grpc_call_element *elem, + grpc_transport_stream_op *op) { + perform_transport_stream_op(elem, op, 0); } static void update_state_locked(channel_data *chand) { - + gpr_log(GPR_ERROR, "update_state_locked not implemented"); } static void cc_on_config_changed(void *arg, int iomgr_success) { @@ -382,9 +388,10 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { if (chand->incoming_configuration) { lb_policy = grpc_client_config_get_lb_policy(chand->incoming_configuration); grpc_lb_policy_ref(lb_policy); + + grpc_client_config_unref(chand->incoming_configuration); } - grpc_client_config_unref(chand->incoming_configuration); chand->incoming_configuration = NULL; gpr_mu_lock(&chand->mu_config); @@ -402,7 +409,9 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { wakeup_closures = next; } - grpc_lb_policy_unref(old_lb_policy); + if (old_lb_policy) { + grpc_lb_policy_unref(old_lb_policy); + } if (iomgr_success) { grpc_resolver_next(chand->resolver, &chand->incoming_configuration, &chand->on_config_changed); @@ -511,6 +520,7 @@ static void init_call_elem(grpc_call_element *elem, GPR_ASSERT(elem->filter == &grpc_client_channel_filter); GPR_ASSERT(server_transport_data == NULL); + gpr_mu_init(&calld->mu_state); calld->elem = elem; calld->state = CALL_CREATED; calld->deadline = gpr_inf_future; @@ -527,7 +537,7 @@ static void destroy_call_elem(grpc_call_element *elem) { gpr_mu_lock(&calld->mu_state); switch (calld->state) { case CALL_ACTIVE: - subchannel_call = calld->s.active.subchannel_call; + subchannel_call = calld->subchannel_call; gpr_mu_unlock(&calld->mu_state); grpc_subchannel_call_unref(subchannel_call); break; @@ -537,6 +547,7 @@ static void destroy_call_elem(grpc_call_element *elem) { break; case CALL_WAITING_FOR_PICK: case CALL_WAITING_FOR_CONFIG: + case CALL_WAITING_FOR_CALL: gpr_log(GPR_ERROR, "should never reach here"); abort(); break; @@ -550,12 +561,12 @@ static void init_channel_elem(grpc_channel_element *elem, int is_last) { channel_data *chand = elem->channel_data; - GPR_ASSERT(!is_first); + memset(chand, 0, sizeof(*chand)); + GPR_ASSERT(is_last); GPR_ASSERT(elem->filter == &grpc_client_channel_filter); gpr_mu_init(&chand->mu_config); - chand->resolver = NULL; chand->mdctx = metadata_context; grpc_iomgr_closure_init(&chand->on_config_changed, cc_on_config_changed, chand); } @@ -633,7 +644,7 @@ grpc_transport_setup_result grpc_client_channel_transport_setup_complete( call_ops = gpr_malloc(sizeof(*call_ops) * waiting_child_count); for (i = 0; i < waiting_child_count; i++) { - call_ops[i] = waiting_children[i]->s.waiting_op; + call_ops[i] = waiting_children[i]->waiting_op; if (!prepare_activate(waiting_children[i]->elem, chand->active_child)) { waiting_children[i] = NULL; grpc_transport_stream_op_finish_with_failure(&call_ops[i]); diff --git a/src/core/client_config/client_config.c b/src/core/client_config/client_config.c index e7d7647b882..bc8dcec54ed 100644 --- a/src/core/client_config/client_config.c +++ b/src/core/client_config/client_config.c @@ -61,7 +61,7 @@ void grpc_client_config_unref(grpc_client_config *c) { void grpc_client_config_set_lb_policy(grpc_client_config *c, grpc_lb_policy *lb_policy) { if (lb_policy) { - grpc_lb_policy_ref(c->lb_policy); + grpc_lb_policy_ref(lb_policy); } if (c->lb_policy) { grpc_lb_policy_unref(c->lb_policy); diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index 46732b8444a..83a25a9a72c 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -32,3 +32,172 @@ */ #include "src/core/client_config/lb_policies/pick_first.h" + +#include + +#include + +typedef struct pending_pick { + struct pending_pick *next; + grpc_pollset *pollset; + grpc_subchannel **target; + grpc_iomgr_closure *on_complete; +} pending_pick; + +typedef struct { + /** base policy: must be first */ + grpc_lb_policy base; + /** ref count */ + gpr_refcount refs; + /** all our subchannels */ + grpc_subchannel **subchannels; + size_t num_subchannels; + + grpc_iomgr_closure connectivity_changed; + + /** mutex protecting remaining members */ + gpr_mu mu; + /** the selected channel + TODO(ctiller): this should be atomically set so we don't + need to take a mutex in the common case */ + grpc_subchannel *selected; + /** have we started picking? */ + int started_picking; + /** which subchannel are we watching? */ + size_t checking_subchannel; + /** what is the connectivity of that channel? */ + grpc_connectivity_state checking_connectivity; + /** list of picks that are waiting on connectivity */ + pending_pick *pending_picks; +} pick_first_lb_policy; + +void pf_ref(grpc_lb_policy *pol) { + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; + gpr_ref(&p->refs); +} + +void pf_unref(grpc_lb_policy *pol) { + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; + if (gpr_unref(&p->refs)) { + gpr_free(p->subchannels); + gpr_mu_destroy(&p->mu); + gpr_free(p); + } +} + +void pf_shutdown(grpc_lb_policy *pol) { + /* pick_first_lb_policy *p = (pick_first_lb_policy*)pol; */ + abort(); +} + +void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, + grpc_metadata_batch *initial_metadata, grpc_subchannel **target, + grpc_iomgr_closure *on_complete) { + pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pending_pick *pp; + gpr_mu_lock(&p->mu); + if (p->selected) { + gpr_mu_unlock(&p->mu); + *target = p->selected; + on_complete->cb(on_complete->cb_arg, 1); + } else { + if (!p->started_picking) { + p->started_picking = 1; + p->checking_subchannel = 0; + p->checking_connectivity = GRPC_CHANNEL_IDLE; + pf_ref(pol); + grpc_subchannel_notify_on_state_change(p->subchannels[0], &p->checking_connectivity, &p->connectivity_changed); + } + grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], pollset); + pp = gpr_malloc(sizeof(*pp)); + pp->next = p->pending_picks; + pp->pollset = pollset; + pp->target = target; + pp->on_complete = on_complete; + p->pending_picks = pp; + gpr_mu_unlock(&p->mu); + } +} + +static void del_interested_parties_locked(pick_first_lb_policy *p) { + pending_pick *pp; + for (pp = p->pending_picks; pp; pp = pp->next) { + grpc_subchannel_del_interested_party(p->subchannels[p->checking_subchannel], pp->pollset); + } +} + +static void add_interested_parties_locked(pick_first_lb_policy *p) { + pending_pick *pp; + for (pp = p->pending_picks; pp; pp = pp->next) { + grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], pp->pollset); + } +} + +static void pf_connectivity_changed(void *arg, int iomgr_success) { + pick_first_lb_policy *p = arg; + pending_pick *pp; + int unref = 0; + + gpr_mu_lock(&p->mu); +loop: + switch (p->checking_connectivity) { + case GRPC_CHANNEL_READY: + p->selected = p->subchannels[p->checking_connectivity]; + while ((pp = p->pending_picks)) { + p->pending_picks = pp->next; + *pp->target = p->selected; + grpc_subchannel_del_interested_party(p->selected, pp->pollset); + grpc_iomgr_add_delayed_callback(pp->on_complete, 1); + gpr_free(pp); + } + unref = 1; + break; + case GRPC_CHANNEL_TRANSIENT_FAILURE: + del_interested_parties_locked(p); + p->checking_subchannel = (p->checking_subchannel + 1) % p->num_subchannels; + p->checking_connectivity = grpc_subchannel_check_connectivity(p->subchannels[p->checking_subchannel]); + add_interested_parties_locked(p); + goto loop; + case GRPC_CHANNEL_CONNECTING: + case GRPC_CHANNEL_IDLE: + grpc_subchannel_notify_on_state_change(p->subchannels[p->checking_subchannel], &p->checking_connectivity, &p->connectivity_changed); + break; + case GRPC_CHANNEL_FATAL_FAILURE: + del_interested_parties_locked(p); + GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel], p->subchannels[p->num_subchannels - 1]); + p->checking_subchannel %= p->num_subchannels; + p->checking_connectivity = grpc_subchannel_check_connectivity(p->subchannels[p->checking_subchannel]); + p->num_subchannels--; + grpc_subchannel_unref(p->subchannels[p->num_subchannels]); + add_interested_parties_locked(p); + if (p->num_subchannels == 0) { + abort(); + } else { + goto loop; + } + } + gpr_mu_unlock(&p->mu); + + if (unref) { + pf_unref(&p->base); + } +} + +static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = { + pf_ref, pf_unref, pf_shutdown, pf_pick}; + +grpc_lb_policy *grpc_create_pick_first_lb_policy(grpc_subchannel **subchannels, + size_t num_subchannels) { + pick_first_lb_policy *p = gpr_malloc(sizeof(*p)); + GPR_ASSERT(num_subchannels); + memset(p, 0, sizeof(*p)); + p->base.vtable = &pick_first_lb_policy_vtable; + gpr_ref_init(&p->refs, 1); + p->subchannels = gpr_malloc(sizeof(grpc_subchannel *) * num_subchannels); + p->num_subchannels = num_subchannels; + memcpy(p->subchannels, subchannels, + sizeof(grpc_subchannel *) * num_subchannels); + grpc_iomgr_closure_init(&p->connectivity_changed, pf_connectivity_changed, p); + gpr_mu_init(&p->mu); + return &p->base; +} diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 4e185d90862..42929e933b3 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -45,7 +45,7 @@ typedef void (*grpc_lb_completion)(void *cb_arg, grpc_subchannel *subchannel, grpc_status_code status, const char *errmsg); struct grpc_lb_policy { - grpc_lb_policy_vtable *vtable; + const grpc_lb_policy_vtable *vtable; }; struct grpc_lb_policy_vtable { diff --git a/src/core/client_config/resolver_factory.c b/src/core/client_config/resolver_factory.c index 378529d5b21..6721977e21a 100644 --- a/src/core/client_config/resolver_factory.c +++ b/src/core/client_config/resolver_factory.c @@ -45,5 +45,6 @@ void grpc_resolver_factory_unref(grpc_resolver_factory *factory) { grpc_resolver *grpc_resolver_factory_create_resolver( grpc_resolver_factory *factory, grpc_uri *uri, grpc_subchannel_factory *subchannel_factory) { + if (!factory) return NULL; return factory->vtable->create_resolver(factory, uri, subchannel_factory); } diff --git a/src/core/client_config/resolver_registry.c b/src/core/client_config/resolver_registry.c index 770d4aca8e9..abdb5f93775 100644 --- a/src/core/client_config/resolver_registry.c +++ b/src/core/client_config/resolver_registry.c @@ -46,57 +46,76 @@ typedef struct { grpc_resolver_factory *factory; } registered_resolver; -static registered_resolver all_of_the_resolvers[MAX_RESOLVERS]; -static int number_of_resolvers = 0; +static registered_resolver g_all_of_the_resolvers[MAX_RESOLVERS]; +static int g_number_of_resolvers = 0; -void grpc_resolver_registry_init(grpc_resolver_factory *r) { - number_of_resolvers = 0; - grpc_register_resolver_type("default-grpc-resolver", r); +static char *g_default_resolver_scheme; + +void grpc_resolver_registry_init(const char *default_resolver_scheme) { + g_number_of_resolvers = 0; + g_default_resolver_scheme = gpr_strdup(default_resolver_scheme); } void grpc_resolver_registry_shutdown(void) { int i; - for (i = 0; i < number_of_resolvers; i++) { - gpr_free(all_of_the_resolvers[i].scheme); - grpc_resolver_factory_unref(all_of_the_resolvers[i].factory); + for (i = 0; i < g_number_of_resolvers; i++) { + gpr_free(g_all_of_the_resolvers[i].scheme); + grpc_resolver_factory_unref(g_all_of_the_resolvers[i].factory); } + gpr_free(g_default_resolver_scheme); } void grpc_register_resolver_type(const char *scheme, grpc_resolver_factory *factory) { int i; - for (i = 0; i < number_of_resolvers; i++) { - GPR_ASSERT(0 != strcmp(scheme, all_of_the_resolvers[i].scheme)); + for (i = 0; i < g_number_of_resolvers; i++) { + GPR_ASSERT(0 != strcmp(scheme, g_all_of_the_resolvers[i].scheme)); } - GPR_ASSERT(number_of_resolvers != MAX_RESOLVERS); - all_of_the_resolvers[number_of_resolvers].scheme = gpr_strdup(scheme); + GPR_ASSERT(g_number_of_resolvers != MAX_RESOLVERS); + g_all_of_the_resolvers[g_number_of_resolvers].scheme = gpr_strdup(scheme); grpc_resolver_factory_ref(factory); - all_of_the_resolvers[number_of_resolvers].factory = factory; - number_of_resolvers++; + g_all_of_the_resolvers[g_number_of_resolvers].factory = factory; + g_number_of_resolvers++; +} + +static grpc_resolver_factory *lookup_factory(grpc_uri *uri) { + int i; + + /* handling NULL uri's here simplifies grpc_resolver_create */ + if (!uri) return NULL; + + for (i = 0; i < g_number_of_resolvers; i++) { + if (0 == strcmp(uri->scheme, g_all_of_the_resolvers[i].scheme)) { + return g_all_of_the_resolvers[i].factory; + } + } + + return NULL; } grpc_resolver *grpc_resolver_create( const char *name, grpc_subchannel_factory *subchannel_factory) { grpc_uri *uri; - int i; char *tmp; - grpc_resolver *resolver = NULL; - if (grpc_has_scheme(name)) { - uri = grpc_uri_parse(name); - if (!uri) { - return NULL; - } - for (i = 0; i < number_of_resolvers; i++) { - if (0 == strcmp(all_of_the_resolvers[i].scheme, uri->scheme)) { - grpc_resolver_factory_create_resolver(all_of_the_resolvers[i].factory, - uri, subchannel_factory); - } + grpc_resolver_factory *factory = NULL; + grpc_resolver *resolver; + + uri = grpc_uri_parse(name); + factory = lookup_factory(uri); + if (factory == NULL && g_default_resolver_scheme != NULL) { + grpc_uri_destroy(uri); + gpr_asprintf(&tmp, "%s%s", g_default_resolver_scheme, name); + uri = grpc_uri_parse(tmp); + factory = lookup_factory(uri); + if (factory == NULL) { + gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", name, tmp); } - } else { - gpr_asprintf(&tmp, "default-grpc-resolver:%s", name); - GPR_ASSERT(grpc_has_scheme(tmp)); - resolver = grpc_resolver_create(tmp, subchannel_factory); gpr_free(tmp); + } else if (factory == NULL) { + gpr_log(GPR_ERROR, "don't know how to resolve '%s'", name); } + resolver = + grpc_resolver_factory_create_resolver(factory, uri, subchannel_factory); + grpc_uri_destroy(uri); return resolver; } diff --git a/src/core/client_config/resolver_registry.h b/src/core/client_config/resolver_registry.h index 53335172da0..31aa47620ab 100644 --- a/src/core/client_config/resolver_registry.h +++ b/src/core/client_config/resolver_registry.h @@ -36,7 +36,7 @@ #include "src/core/client_config/resolver_factory.h" -void grpc_resolver_registry_init(grpc_resolver_factory *default_resolver); +void grpc_resolver_registry_init(const char *default_prefix); void grpc_resolver_registry_shutdown(void); /** Register a resolver type. @@ -47,7 +47,15 @@ void grpc_resolver_registry_shutdown(void); void grpc_register_resolver_type(const char *scheme, grpc_resolver_factory *factory); -/** Create a resolver given a \a uri string (with an optional scheme prefix) */ +/** Create a resolver given \a name. + First tries to parse \a name as a URI. If this succeeds, tries + to locate a registered resolver factory based on the URI scheme. + If parsing or location fails, prefixes default_prefix from + grpc_resolver_registry_init to name, and tries again (if default_prefix + was not NULL). + If a resolver factory was found, use it to instantiate a resolver and + return it. + If a resolver factory was not found, return NULL. */ grpc_resolver *grpc_resolver_create( const char *name, grpc_subchannel_factory *subchannel_factory); diff --git a/src/core/client_config/resolvers/dns_resolver.c b/src/core/client_config/resolvers/dns_resolver.c index 95f38ecab75..ba826752750 100644 --- a/src/core/client_config/resolvers/dns_resolver.c +++ b/src/core/client_config/resolvers/dns_resolver.c @@ -38,6 +38,7 @@ #include #include +#include "src/core/client_config/lb_policies/pick_first.h" #include "src/core/iomgr/resolve_address.h" #include "src/core/support/string.h" @@ -177,6 +178,8 @@ static void dns_start_resolving_locked(dns_resolver *r) { static void dns_maybe_finish_next_locked(dns_resolver *r) { if (r->next_completion != NULL && r->resolved_version != r->published_version) { + *r->target_config = r->resolved_config; + grpc_client_config_ref(r->resolved_config); grpc_iomgr_add_callback(r->next_completion); r->next_completion = NULL; r->published_version = r->resolved_version; @@ -191,8 +194,11 @@ static void dns_destroy(dns_resolver *r) { gpr_free(r); } -static grpc_resolver *dns_create(grpc_uri *uri, const char *default_port, - grpc_subchannel_factory *subchannel_factory) { +static grpc_resolver *dns_create( + grpc_uri *uri, const char *default_port, + grpc_lb_policy *(*lb_policy_factory)(grpc_subchannel **subchannels, + size_t num_subchannels), + grpc_subchannel_factory *subchannel_factory) { dns_resolver *r; const char *path = uri->path; @@ -211,6 +217,7 @@ static grpc_resolver *dns_create(grpc_uri *uri, const char *default_port, r->name = gpr_strdup(path); r->default_port = gpr_strdup(default_port); r->subchannel_factory = subchannel_factory; + r->lb_policy_factory = lb_policy_factory; grpc_subchannel_factory_ref(subchannel_factory); return &r->base; } @@ -219,43 +226,21 @@ static grpc_resolver *dns_create(grpc_uri *uri, const char *default_port, * FACTORY */ -typedef struct { - /** base: must be first */ - grpc_resolver_factory base; - /** ref count */ - gpr_refcount refs; - /** default port */ - char *default_port; -} dns_resolver_factory; - -static void dns_factory_ref(grpc_resolver_factory *factory) { - dns_resolver_factory *f = (dns_resolver_factory *)factory; - gpr_ref(&f->refs); -} +static void dns_factory_ref(grpc_resolver_factory *factory) {} -static void dns_factory_unref(grpc_resolver_factory *factory) { - dns_resolver_factory *f = (dns_resolver_factory *)factory; - if (gpr_unref(&f->refs)) { - gpr_free(f->default_port); - gpr_free(f); - } -} +static void dns_factory_unref(grpc_resolver_factory *factory) {} static grpc_resolver *dns_factory_create_resolver( grpc_resolver_factory *factory, grpc_uri *uri, grpc_subchannel_factory *subchannel_factory) { - dns_resolver_factory *f = (dns_resolver_factory *)factory; - return dns_create(uri, f->default_port, subchannel_factory); + return dns_create(uri, "https", grpc_create_pick_first_lb_policy, + subchannel_factory); } static const grpc_resolver_factory_vtable dns_factory_vtable = { dns_factory_ref, dns_factory_unref, dns_factory_create_resolver}; +static grpc_resolver_factory dns_resolver_factory = {&dns_factory_vtable}; -grpc_resolver_factory *grpc_dns_resolver_factory_create( - const char *default_port) { - dns_resolver_factory *f = gpr_malloc(sizeof(*f)); - memset(f, 0, sizeof(*f)); - f->base.vtable = &dns_factory_vtable; - f->default_port = gpr_strdup(default_port); - return &f->base; +grpc_resolver_factory *grpc_dns_resolver_factory_create() { + return &dns_resolver_factory; } diff --git a/src/core/client_config/resolvers/dns_resolver.h b/src/core/client_config/resolvers/dns_resolver.h index 9881448fd8e..09322b16cf3 100644 --- a/src/core/client_config/resolvers/dns_resolver.h +++ b/src/core/client_config/resolvers/dns_resolver.h @@ -37,7 +37,6 @@ #include "src/core/client_config/resolver_factory.h" /** Create a dns resolver for \a name */ -grpc_resolver_factory *grpc_dns_resolver_factory_create( - const char *default_port); +grpc_resolver_factory *grpc_dns_resolver_factory_create(void); #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H */ diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 037f0c0ab04..9637cf39fec 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -37,6 +37,13 @@ #include +#include "src/core/channel/channel_args.h" + +typedef struct { + gpr_refcount refs; + grpc_subchannel *subchannel; +} connection; + struct grpc_subchannel { gpr_refcount refs; grpc_connector *connector; @@ -49,24 +56,45 @@ struct grpc_subchannel { /** address to connect to */ struct sockaddr *addr; size_t addr_len; + + /** set during connection */ + grpc_transport *connecting_transport; + + /** callback for connection finishing */ + grpc_iomgr_closure connected; + + /** mutex protecting remaining elements */ + gpr_mu mu; + + /** active connection */ + connection *active; + /** are we connecting */ + int connecting; + /** closures waiting for a connection */ + grpc_iomgr_closure *waiting; }; struct grpc_subchannel_call { - grpc_subchannel *subchannel; + connection *connection; gpr_refcount refs; }; #define SUBCHANNEL_CALL_TO_CALL_STACK(call) (((grpc_call_stack *)(call)) + 1) +static grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op); + /* * grpc_subchannel implementation */ -void grpc_subchannel_ref(grpc_subchannel *channel) { gpr_ref(&channel->refs); } +void grpc_subchannel_ref(grpc_subchannel *c) { gpr_ref(&c->refs); } -void grpc_subchannel_unref(grpc_subchannel *channel) { - if (gpr_unref(&channel->refs)) { - gpr_free(channel); +void grpc_subchannel_unref(grpc_subchannel *c) { + if (gpr_unref(&c->refs)) { + gpr_free(c->filters); + grpc_channel_args_destroy(c->args); + gpr_free(c->addr); + gpr_free(c); } } @@ -84,9 +112,39 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, c->addr = gpr_malloc(args->addr_len); memcpy(c->addr, args->addr, args->addr_len); c->addr_len = args->addr_len; + c->args = grpc_channel_args_copy(args->args); + gpr_mu_init(&c->mu); return c; } +void grpc_subchannel_create_call(grpc_subchannel *c, + grpc_mdctx *mdctx, + grpc_transport_stream_op *initial_op, + grpc_subchannel_call **target, + grpc_iomgr_closure *notify) { + connection *con; + gpr_mu_lock(&c->mu); + if (c->active != NULL) { + con = c->active; + gpr_ref(&con->refs); + gpr_mu_unlock(&c->mu); + + *target = create_call(con, initial_op); + notify->cb(notify->cb_arg, 1); + } else { + notify->next = c->waiting; + c->waiting = notify; + if (!c->connecting) { + c->connecting = 1; + gpr_mu_unlock(&c->mu); + + grpc_connector_connect(c->connector, c->args, mdctx, &c->connecting_transport, &c->connected); + } else { + gpr_mu_unlock(&c->mu); + } + } +} + /* * grpc_subchannel_call implementation */ @@ -98,7 +156,9 @@ void grpc_subchannel_call_ref(grpc_subchannel_call *call) { void grpc_subchannel_call_unref(grpc_subchannel_call *call) { if (gpr_unref(&call->refs)) { grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(call)); - grpc_subchannel_unref(call->subchannel); + if (gpr_unref(&call->connection->refs)) { + gpr_free(call->connection); + } gpr_free(call); } } @@ -109,3 +169,8 @@ void grpc_subchannel_call_process_op(grpc_subchannel_call *call, grpc_call_element *top_elem = grpc_call_stack_element(call_stack, 0); top_elem->filter->start_transport_stream_op(top_elem, op); } + +grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op) { + abort(); + return NULL; +} diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index b4d40eadfa0..8b3d82eb0ad 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -59,9 +59,12 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, grpc_connectivity_state *state, grpc_iomgr_closure *notify); +void grpc_subchannel_add_interested_party(grpc_subchannel *channel, grpc_pollset *pollset); +void grpc_subchannel_del_interested_party(grpc_subchannel *channel, grpc_pollset *pollset); + /** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, - grpc_call_element *parent, + grpc_mdctx *mdctx, grpc_transport_stream_op *initial_op, grpc_subchannel_call **target, grpc_iomgr_closure *notify); diff --git a/src/core/client_config/subchannel_factory.c b/src/core/client_config/subchannel_factory.c index 06e8a4bdaf6..f71386594c0 100644 --- a/src/core/client_config/subchannel_factory.c +++ b/src/core/client_config/subchannel_factory.c @@ -32,3 +32,15 @@ */ #include "src/core/client_config/subchannel_factory.h" + +void grpc_subchannel_factory_ref(grpc_subchannel_factory *factory) { + factory->vtable->ref(factory); +} +void grpc_subchannel_factory_unref(grpc_subchannel_factory *factory) { + factory->vtable->unref(factory); +} + +grpc_subchannel *grpc_subchannel_factory_create_subchannel( + grpc_subchannel_factory *factory, grpc_subchannel_args *args) { + return factory->vtable->create_subchannel(factory, args); +} diff --git a/src/core/client_config/uri_parser.c b/src/core/client_config/uri_parser.c index 24dfaae4970..43b5b47f55e 100644 --- a/src/core/client_config/uri_parser.c +++ b/src/core/client_config/uri_parser.c @@ -64,30 +64,6 @@ static char *copy_fragment(const char *src, int begin, int end) { return out; } -int grpc_has_scheme(const char *uri_text) { - int scheme_begin = 0; - int scheme_end = -1; - int i; - - for (i = scheme_begin; uri_text[i] != 0; i++) { - if (uri_text[i] == ':') { - scheme_end = i; - break; - } - if (uri_text[i] >= 'a' && uri_text[i] <= 'z') continue; - if (uri_text[i] >= 'A' && uri_text[i] <= 'Z') continue; - if (i != scheme_begin) { - if (uri_text[i] >= '0' && uri_text[i] <= '9') continue; - if (uri_text[i] == '+') continue; - if (uri_text[i] == '-') continue; - if (uri_text[i] == '.') continue; - } - break; - } - - return scheme_end != -1; -} - grpc_uri *grpc_uri_parse(const char *uri_text) { grpc_uri *uri; int scheme_begin = 0; @@ -162,6 +138,7 @@ grpc_uri *grpc_uri_parse(const char *uri_text) { } void grpc_uri_destroy(grpc_uri *uri) { + if (!uri) return; gpr_free(uri->scheme); gpr_free(uri->authority); gpr_free(uri->path); diff --git a/src/core/client_config/uri_parser.h b/src/core/client_config/uri_parser.h index 0e21d568a9c..b6821f9621e 100644 --- a/src/core/client_config/uri_parser.h +++ b/src/core/client_config/uri_parser.h @@ -43,9 +43,6 @@ typedef struct { /** parse a uri, return NULL on failure */ grpc_uri *grpc_uri_parse(const char *uri_text); -/** return 1 if uri_text has something that is likely a scheme, 0 otherwise */ -int grpc_has_scheme(const char *uri_text); - /** destroy a uri */ void grpc_uri_destroy(grpc_uri *uri); diff --git a/src/core/surface/init.c b/src/core/surface/init.c index ca61a38a351..03add814661 100644 --- a/src/core/surface/init.c +++ b/src/core/surface/init.c @@ -34,6 +34,8 @@ #include #include #include "src/core/channel/channel_stack.h" +#include "src/core/client_config/resolver_registry.h" +#include "src/core/client_config/resolvers/dns_resolver.h" #include "src/core/debug/trace.h" #include "src/core/iomgr/iomgr.h" #include "src/core/profiling/timers.h" @@ -56,6 +58,8 @@ void grpc_init(void) { gpr_mu_lock(&g_init_mu); if (++g_initializations == 1) { + grpc_resolver_registry_init("dns:///"); + grpc_register_resolver_type("dns", grpc_dns_resolver_factory_create()); grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer("surface", &grpc_surface_trace); grpc_register_tracer("http", &grpc_http_trace); diff --git a/test/core/end2end/fixtures/chttp2_fullstack.c b/test/core/end2end/fixtures/chttp2_fullstack.c index e647434509d..8a1530e63b0 100644 --- a/test/core/end2end/fixtures/chttp2_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_fullstack.c @@ -73,6 +73,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { fullstack_fixture_data *ffd = f->fixture_data; f->client = grpc_channel_create(ffd->localaddr, client_args); + GPR_ASSERT(f->client); } void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, From 5f84c8478ab61c30cc98d956bbe327e02142d2e6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 26 Jun 2015 16:08:21 -0700 Subject: [PATCH 042/124] Connector progress --- src/core/channel/client_channel.c | 5 +- src/core/client_config/connector.c | 14 +-- src/core/client_config/connector.h | 16 ++-- src/core/client_config/subchannel.c | 130 ++++++++++++++++++++++++++-- src/core/client_config/subchannel.h | 3 +- src/core/surface/channel_create.c | 67 ++++++++++++-- 6 files changed, 205 insertions(+), 30 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 965d4e53dc6..dc838de7153 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -249,7 +249,6 @@ static void started_call(void *arg, int iomgr_success) { static void picked_target(void *arg, int iomgr_success) { call_data *calld = arg; - channel_data *chand = calld->elem->channel_data; grpc_transport_stream_op op; if (calld->picked_channel == NULL) { @@ -268,7 +267,9 @@ static void picked_target(void *arg, int iomgr_success) { memset(&calld->waiting_op, 0, sizeof(calld->waiting_op)); gpr_mu_unlock(&calld->mu_state); grpc_iomgr_closure_init(&calld->async_setup_task, started_call, calld); - grpc_subchannel_create_call(calld->picked_channel, chand->mdctx, &op, &calld->subchannel_call, &calld->async_setup_task); + grpc_subchannel_create_call(calld->picked_channel, &op, + &calld->subchannel_call, + &calld->async_setup_task); } } } diff --git a/src/core/client_config/connector.c b/src/core/client_config/connector.c index c3a8962ea66..60c392f85b5 100644 --- a/src/core/client_config/connector.c +++ b/src/core/client_config/connector.c @@ -41,11 +41,11 @@ void grpc_connector_unref(grpc_connector *connector) { connector->vtable->unref(connector); } -void grpc_connector_connect(grpc_connector *connector, - const grpc_channel_args *channel_args, - grpc_mdctx *metadata_context, - grpc_transport **transport, - grpc_iomgr_closure *notify) { - connector->vtable->connect(connector, channel_args, metadata_context, - transport, notify); +void grpc_connector_connect( + grpc_connector *connector, grpc_pollset_set *pollset_set, + const struct sockaddr *addr, int addr_len, gpr_timespec deadline, + const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, + grpc_transport **transport, grpc_iomgr_closure *notify) { + connector->vtable->connect(connector, pollset_set, addr, addr_len, deadline, + channel_args, metadata_context, transport, notify); } diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h index 8ada75ec708..72414377293 100644 --- a/src/core/client_config/connector.h +++ b/src/core/client_config/connector.h @@ -34,6 +34,7 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H +#include "src/core/iomgr/sockaddr.h" #include "src/core/transport/transport.h" typedef struct grpc_connector grpc_connector; @@ -46,18 +47,19 @@ struct grpc_connector { struct grpc_connector_vtable { void (*ref)(grpc_connector *connector); void (*unref)(grpc_connector *connector); - void (*connect)(grpc_connector *connector, - const grpc_channel_args *channel_args, + void (*connect)(grpc_connector *connector, grpc_pollset_set *pollset_set, + const struct sockaddr *addr, int addr_len, + gpr_timespec deadline, const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, grpc_transport **transport, grpc_iomgr_closure *notify); }; void grpc_connector_ref(grpc_connector *connector); void grpc_connector_unref(grpc_connector *connector); -void grpc_connector_connect(grpc_connector *connector, - const grpc_channel_args *channel_args, - grpc_mdctx *metadata_context, - grpc_transport **transport, - grpc_iomgr_closure *notify); +void grpc_connector_connect( + grpc_connector *connector, grpc_pollset_set *pollset_set, + const struct sockaddr *addr, int addr_len, gpr_timespec deadline, + const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, + grpc_transport **transport, grpc_iomgr_closure *notify); #endif diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 9637cf39fec..2b4c7ea1d38 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -44,6 +44,19 @@ typedef struct { grpc_subchannel *subchannel; } connection; +typedef struct waiting_for_connect { + struct waiting_for_connect *next; + grpc_iomgr_closure *notify; + grpc_transport_stream_op *initial_op; + grpc_subchannel_call **target; +} waiting_for_connect; + +typedef struct connectivity_state_watcher { + struct connectivity_state_watcher *next; + grpc_iomgr_closure *notify; + grpc_connectivity_state *current; +} connectivity_state_watcher; + struct grpc_subchannel { gpr_refcount refs; grpc_connector *connector; @@ -56,6 +69,8 @@ struct grpc_subchannel { /** address to connect to */ struct sockaddr *addr; size_t addr_len; + /** metadata context */ + grpc_mdctx *mdctx; /** set during connection */ grpc_transport *connecting_transport; @@ -63,6 +78,10 @@ struct grpc_subchannel { /** callback for connection finishing */ grpc_iomgr_closure connected; + /** pollset_set tracking who's interested in a connection + being setup */ + grpc_pollset_set pollset_set; + /** mutex protecting remaining elements */ gpr_mu mu; @@ -70,8 +89,10 @@ struct grpc_subchannel { connection *active; /** are we connecting */ int connecting; - /** closures waiting for a connection */ - grpc_iomgr_closure *waiting; + /** things waiting for a connection */ + waiting_for_connect *waiting; + /** things watching the connectivity state */ + connectivity_state_watcher *watchers; }; struct grpc_subchannel_call { @@ -82,6 +103,9 @@ struct grpc_subchannel_call { #define SUBCHANNEL_CALL_TO_CALL_STACK(call) (((grpc_call_stack *)(call)) + 1) static grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op); +static void connectivity_state_changed_locked(grpc_subchannel *c); +static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); +static gpr_timespec compute_connect_deadline(grpc_subchannel *c); /* * grpc_subchannel implementation @@ -94,10 +118,21 @@ void grpc_subchannel_unref(grpc_subchannel *c) { gpr_free(c->filters); grpc_channel_args_destroy(c->args); gpr_free(c->addr); + grpc_mdctx_unref(c->mdctx); gpr_free(c); } } +void grpc_subchannel_add_interested_party(grpc_subchannel *c, + grpc_pollset *pollset) { + grpc_pollset_set_add_pollset(&c->pollset_set, pollset); +} + +void grpc_subchannel_del_interested_party(grpc_subchannel *c, + grpc_pollset *pollset) { + grpc_pollset_set_del_pollset(&c->pollset_set, pollset); +} + grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, grpc_subchannel_args *args) { grpc_subchannel *c = gpr_malloc(sizeof(*c)); @@ -113,12 +148,13 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, memcpy(c->addr, args->addr, args->addr_len); c->addr_len = args->addr_len; c->args = grpc_channel_args_copy(args->args); + c->mdctx = args->mdctx; + grpc_mdctx_ref(c->mdctx); gpr_mu_init(&c->mu); return c; } void grpc_subchannel_create_call(grpc_subchannel *c, - grpc_mdctx *mdctx, grpc_transport_stream_op *initial_op, grpc_subchannel_call **target, grpc_iomgr_closure *notify) { @@ -132,19 +168,101 @@ void grpc_subchannel_create_call(grpc_subchannel *c, *target = create_call(con, initial_op); notify->cb(notify->cb_arg, 1); } else { - notify->next = c->waiting; - c->waiting = notify; + waiting_for_connect *w4c = gpr_malloc(sizeof(*w4c)); + w4c->next = c->waiting; + w4c->notify = notify; + w4c->initial_op = initial_op; + w4c->target = target; + c->waiting = w4c; + grpc_subchannel_add_interested_party(c, initial_op->bind_pollset); if (!c->connecting) { c->connecting = 1; + connectivity_state_changed_locked(c); gpr_mu_unlock(&c->mu); - grpc_connector_connect(c->connector, c->args, mdctx, &c->connecting_transport, &c->connected); + grpc_connector_connect(c->connector, &c->pollset_set, c->addr, + c->addr_len, compute_connect_deadline(c), c->args, + c->mdctx, &c->connecting_transport, &c->connected); } else { gpr_mu_unlock(&c->mu); } } } +grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel *c) { + grpc_connectivity_state state; + gpr_mu_lock(&c->mu); + state = compute_connectivity_locked(c); + gpr_mu_unlock(&c->mu); + return state; +} + +void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, + grpc_connectivity_state *state, + grpc_iomgr_closure *notify) { + grpc_connectivity_state current; + int do_connect = 0; + connectivity_state_watcher *w = gpr_malloc(sizeof(*w)); + w->current = state; + w->notify = notify; + gpr_mu_lock(&c->mu); + current = compute_connectivity_locked(c); + if (current == GRPC_CHANNEL_IDLE) { + current = GRPC_CHANNEL_CONNECTING; + c->connecting = 1; + do_connect = 1; + connectivity_state_changed_locked(c); + } + if (current != *state) { + gpr_mu_unlock(&c->mu); + *state = current; + grpc_iomgr_add_callback(notify); + gpr_free(w); + } else { + w->next = c->watchers; + c->watchers = w; + gpr_mu_unlock(&c->mu); + } + if (do_connect) { + grpc_connector_connect(c->connector, &c->pollset_set, c->addr, c->addr_len, + compute_connect_deadline(c), c->args, c->mdctx, + &c->connecting_transport, &c->connected); + } +} + +static gpr_timespec compute_connect_deadline(grpc_subchannel *c) { + return gpr_time_add(gpr_now(), gpr_time_from_seconds(60)); +} + +static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { + if (c->connecting) { + return GRPC_CHANNEL_CONNECTING; + } + if (c->active) { + return GRPC_CHANNEL_READY; + } + return GRPC_CHANNEL_IDLE; +} + +static void connectivity_state_changed_locked(grpc_subchannel *c) { + grpc_connectivity_state current = compute_connectivity_locked(c); + connectivity_state_watcher *new = NULL; + connectivity_state_watcher *w; + while ((w = c->watchers)) { + c->watchers = w->next; + + if (current != *w->current) { + *w->current = current; + grpc_iomgr_add_callback(w->notify); + gpr_free(w); + } else { + w->next = new; + new = w; + } + } + c->watchers = new; +} + /* * grpc_subchannel_call implementation */ diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 8b3d82eb0ad..8836f9b09c1 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -64,7 +64,6 @@ void grpc_subchannel_del_interested_party(grpc_subchannel *channel, grpc_pollset /** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, - grpc_mdctx *mdctx, grpc_transport_stream_op *initial_op, grpc_subchannel_call **target, grpc_iomgr_closure *notify); @@ -84,6 +83,8 @@ struct grpc_subchannel_args { /** Address to connect to */ struct sockaddr *addr; size_t addr_len; + /** metadata context to use */ + grpc_mdctx *mdctx; }; /** create a subchannel given a connector */ diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index ba4e1a24ecc..46d1d708dd7 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -41,11 +41,18 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/client_channel.h" #include "src/core/client_config/resolver_registry.h" +#include "src/core/iomgr/tcp_client.h" #include "src/core/surface/channel.h" +#include "src/core/transport/chttp2_transport.h" typedef struct { grpc_connector base; gpr_refcount refs; + + grpc_transport **transport; + grpc_iomgr_closure *notify; + const grpc_channel_args *args; + grpc_mdctx *mdctx; } connector; static void connector_ref(grpc_connector *con) { @@ -60,28 +67,68 @@ static void connector_unref(grpc_connector *con) { } } -static void connector_connect(grpc_connector *connector, const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, grpc_transport **transport, grpc_iomgr_closure *notify) { - abort(); +static void connected(void *arg, grpc_endpoint *tcp) { + connector *c = arg; + grpc_iomgr_closure *notify; + if (tcp != NULL) { + *c->transport = + grpc_create_chttp2_transport(c->args, tcp, NULL, 0, c->mdctx, 1); + } else { + *c->transport = NULL; + } + notify = c->notify; + c->notify = NULL; + grpc_iomgr_add_callback(notify); +} + +static void connector_connect( + grpc_connector *con, grpc_pollset_set *pollset_set, + const struct sockaddr *addr, int addr_len, gpr_timespec deadline, + const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, + grpc_transport **transport, grpc_iomgr_closure *notify) { + connector *c = (connector *)con; + GPR_ASSERT(c->notify == NULL); + c->notify = notify; + c->args = channel_args; + c->mdctx = metadata_context; + grpc_tcp_client_connect(connected, c, pollset_set, addr, addr_len, deadline); } static const grpc_connector_vtable connector_vtable = {connector_ref, connector_unref, connector_connect}; -static void subchannel_factory_ref(grpc_subchannel_factory *scf) {} +typedef struct { + grpc_subchannel_factory base; + gpr_refcount refs; + grpc_mdctx *mdctx; +} subchannel_factory; + +static void subchannel_factory_ref(grpc_subchannel_factory *scf) { + subchannel_factory *f = (subchannel_factory *)scf; + gpr_ref(&f->refs); +} -static void subchannel_factory_unref(grpc_subchannel_factory *scf) {} +static void subchannel_factory_unref(grpc_subchannel_factory *scf) { + subchannel_factory *f = (subchannel_factory *)scf; + if (gpr_unref(&f->refs)) { + grpc_mdctx_unref(f->mdctx); + gpr_free(f); + } +} static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { + subchannel_factory *f = (subchannel_factory *)scf; connector *c = gpr_malloc(sizeof(*c)); grpc_subchannel *s; + memset(c, 0, sizeof(*c)); c->base.vtable = &connector_vtable; gpr_ref_init(&c->refs, 1); + args->mdctx = f->mdctx; s = grpc_subchannel_create(&c->base, args); grpc_connector_unref(&c->base); return s; } static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchannel_factory_ref, subchannel_factory_unref, subchannel_factory_create_subchannel}; -static grpc_subchannel_factory subchannel_factory = {&subchannel_factory_vtable}; /* Create a client channel: Asynchronously: - resolve target @@ -93,6 +140,8 @@ grpc_channel *grpc_channel_create(const char *target, #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; grpc_resolver *resolver; + subchannel_factory *f; + grpc_mdctx *mdctx = grpc_mdctx_create(); int n = 0; /* TODO(census) if (grpc_channel_args_is_census_enabled(args)) { @@ -101,12 +150,16 @@ grpc_channel *grpc_channel_create(const char *target, filters[n++] = &grpc_client_channel_filter; GPR_ASSERT(n <= MAX_FILTERS); - resolver = grpc_resolver_create(target, &subchannel_factory); + f = gpr_malloc(sizeof(*f)); + f->base.vtable = &subchannel_factory_vtable; + gpr_ref_init(&f->refs, 1); + f->mdctx = mdctx; + resolver = grpc_resolver_create(target, &f->base); if (!resolver) { return NULL; } - channel = grpc_channel_create_from_filters(filters, n, args, grpc_mdctx_create(), 1); + channel = grpc_channel_create_from_filters(filters, n, args, mdctx, 1); grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); return channel; From 4b804104b67c1c10b358877ed5090df62c422fc1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 26 Jun 2015 16:16:12 -0700 Subject: [PATCH 043/124] Small fixes --- src/core/iomgr/iomgr.c | 1 + src/core/surface/channel_create.c | 1 + src/core/surface/server.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c index c47528aa94b..2765706de8c 100644 --- a/src/core/iomgr/iomgr.c +++ b/src/core/iomgr/iomgr.c @@ -203,6 +203,7 @@ void grpc_iomgr_closure_init(grpc_iomgr_closure *closure, grpc_iomgr_cb_func cb, void grpc_iomgr_add_delayed_callback(grpc_iomgr_closure *closure, int success) { closure->success = success; + GPR_ASSERT(closure->cb); gpr_mu_lock(&g_mu); closure->next = NULL; if (!g_cbs_tail) { diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 46d1d708dd7..a98f550ede4 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -91,6 +91,7 @@ static void connector_connect( c->notify = notify; c->args = channel_args; c->mdctx = metadata_context; + c->transport = transport; grpc_tcp_client_connect(connected, c, pollset_set, addr, addr_len, deadline); } diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 98e0e81eaae..f4d76e882fa 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -916,14 +916,6 @@ void grpc_server_setup_transport(grpc_server *s, grpc_transport *transport, server_ref(s); chand->channel = channel; - GRPC_CHANNEL_INTERNAL_REF(channel, "connectivity"); - memset(&op, 0, sizeof(op)); - op.set_accept_stream = accept_stream; - op.set_accept_stream_user_data = chand; - op.on_connectivity_state_change = &chand->channel_connectivity_changed; - op.connectivity_state = &chand->connectivity_state; - grpc_transport_perform_op(transport, &op); - num_registered_methods = 0; for (rm = s->registered_methods; rm; rm = rm->next) { num_registered_methods++; @@ -963,6 +955,14 @@ void grpc_server_setup_transport(grpc_server *s, grpc_transport *transport, gpr_mu_unlock(&s->mu_global); gpr_free(filters); + + GRPC_CHANNEL_INTERNAL_REF(channel, "connectivity"); + memset(&op, 0, sizeof(op)); + op.set_accept_stream = accept_stream; + op.set_accept_stream_user_data = chand; + op.on_connectivity_state_change = &chand->channel_connectivity_changed; + op.connectivity_state = &chand->connectivity_state; + grpc_transport_perform_op(transport, &op); } void grpc_server_shutdown_and_notify(grpc_server *server, From ff54c92adc8c46a0cdce74d06f98faea14f52100 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 26 Jun 2015 16:57:20 -0700 Subject: [PATCH 044/124] Get the success case through to call creation --- src/core/channel/connected_channel.c | 1 - .../client_config/lb_policies/pick_first.c | 5 ++- src/core/client_config/subchannel.c | 45 ++++++++++++++++++- src/core/surface/channel_create.c | 1 + 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 80a3100af05..84caecb6b35 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -107,7 +107,6 @@ static void init_channel_elem(grpc_channel_element *elem, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { channel_data *cd = (channel_data *)elem->channel_data; - GPR_ASSERT(!is_first); GPR_ASSERT(is_last); GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); cd->transport = NULL; diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index 83a25a9a72c..f3a6d21eb56 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -106,7 +106,7 @@ void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, p->checking_subchannel = 0; p->checking_connectivity = GRPC_CHANNEL_IDLE; pf_ref(pol); - grpc_subchannel_notify_on_state_change(p->subchannels[0], &p->checking_connectivity, &p->connectivity_changed); + grpc_subchannel_notify_on_state_change(p->subchannels[p->checking_subchannel], &p->checking_connectivity, &p->connectivity_changed); } grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], pollset); pp = gpr_malloc(sizeof(*pp)); @@ -142,7 +142,8 @@ static void pf_connectivity_changed(void *arg, int iomgr_success) { loop: switch (p->checking_connectivity) { case GRPC_CHANNEL_READY: - p->selected = p->subchannels[p->checking_connectivity]; + p->selected = p->subchannels[p->checking_subchannel]; + GPR_ASSERT(grpc_subchannel_check_connectivity(p->selected) == GRPC_CHANNEL_READY); while ((pp = p->pending_picks)) { p->pending_picks = pp->next; *pp->target = p->selected; diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 2b4c7ea1d38..e863c5b97cc 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -38,6 +38,7 @@ #include #include "src/core/channel/channel_args.h" +#include "src/core/channel/connected_channel.h" typedef struct { gpr_refcount refs; @@ -106,6 +107,7 @@ static grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_ static void connectivity_state_changed_locked(grpc_subchannel *c); static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); static gpr_timespec compute_connect_deadline(grpc_subchannel *c); +static void subchannel_connected(void *subchannel, int iomgr_success); /* * grpc_subchannel implementation @@ -119,6 +121,7 @@ void grpc_subchannel_unref(grpc_subchannel *c) { grpc_channel_args_destroy(c->args); gpr_free(c->addr); grpc_mdctx_unref(c->mdctx); + grpc_pollset_set_destroy(&c->pollset_set); gpr_free(c); } } @@ -140,16 +143,19 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, gpr_ref_init(&c->refs, 1); c->connector = connector; grpc_connector_ref(c->connector); - c->filters = gpr_malloc(sizeof(grpc_channel_filter *) * args->filter_count); + c->filter_count = args->filter_count + 1; + c->filters = gpr_malloc(sizeof(grpc_channel_filter *) * c->filter_count); memcpy(c->filters, args->filters, sizeof(grpc_channel_filter *) * args->filter_count); - c->filter_count = args->filter_count; + c->filters[c->filter_count - 1] = &grpc_connected_channel_filter; c->addr = gpr_malloc(args->addr_len); memcpy(c->addr, args->addr, args->addr_len); c->addr_len = args->addr_len; c->args = grpc_channel_args_copy(args->args); c->mdctx = args->mdctx; grpc_mdctx_ref(c->mdctx); + grpc_pollset_set_init(&c->pollset_set); + grpc_iomgr_closure_init(&c->connected, subchannel_connected, c); gpr_mu_init(&c->mu); return c; } @@ -178,6 +184,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, if (!c->connecting) { c->connecting = 1; connectivity_state_changed_locked(c); + grpc_subchannel_ref(c); gpr_mu_unlock(&c->mu); grpc_connector_connect(c->connector, &c->pollset_set, c->addr, @@ -211,6 +218,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, current = GRPC_CHANNEL_CONNECTING; c->connecting = 1; do_connect = 1; + grpc_subchannel_ref(c); connectivity_state_changed_locked(c); } if (current != *state) { @@ -230,6 +238,39 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, } } +static void publish_transport(grpc_subchannel *c) { + size_t channel_stack_size = grpc_channel_stack_size(c->filters, c->filter_count); + connection *con = gpr_malloc(sizeof(connection) + channel_stack_size); + grpc_channel_stack *stk = (grpc_channel_stack *)(con + 1); + waiting_for_connect *w4c; + gpr_ref_init(&con->refs, 1); + con->subchannel = c; + grpc_channel_stack_init(c->filters, c->filter_count, c->args, c->mdctx, stk); + grpc_connected_channel_bind_transport(stk, c->connecting_transport); + c->connecting_transport = NULL; + + gpr_mu_lock(&c->mu); + GPR_ASSERT(c->active == NULL); + c->active = con; + c->connecting = 0; + connectivity_state_changed_locked(c); + while ((w4c = c->waiting)) { + abort(); /* not implemented */ + } + gpr_mu_unlock(&c->mu); +} + +static void subchannel_connected(void *arg, int iomgr_success) { + grpc_subchannel *c = arg; + if (c->connecting_transport) { + publish_transport(c); + } else { + grpc_subchannel_unref(c); + /* TODO(ctiller): retry after sleeping */ + abort(); + } +} + static gpr_timespec compute_connect_deadline(grpc_subchannel *c) { return gpr_time_add(gpr_now(), gpr_time_from_seconds(60)); } diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index a98f550ede4..3d54ff58d82 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -88,6 +88,7 @@ static void connector_connect( grpc_transport **transport, grpc_iomgr_closure *notify) { connector *c = (connector *)con; GPR_ASSERT(c->notify == NULL); + GPR_ASSERT(notify->cb); c->notify = notify; c->args = channel_args; c->mdctx = metadata_context; From 04c5d4b8fda632af2fc0bec1ca7ed1b276b1969b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 26 Jun 2015 17:21:41 -0700 Subject: [PATCH 045/124] Progress - need to add http filters --- src/core/client_config/connector.c | 11 ++++---- src/core/client_config/connector.h | 38 ++++++++++++++++++++------ src/core/client_config/subchannel.c | 41 ++++++++++++++++++++--------- src/core/surface/channel_create.c | 24 +++++++---------- src/core/surface/server.c | 2 ++ 5 files changed, 75 insertions(+), 41 deletions(-) diff --git a/src/core/client_config/connector.c b/src/core/client_config/connector.c index 60c392f85b5..9cc57ddf38c 100644 --- a/src/core/client_config/connector.c +++ b/src/core/client_config/connector.c @@ -42,10 +42,9 @@ void grpc_connector_unref(grpc_connector *connector) { } void grpc_connector_connect( - grpc_connector *connector, grpc_pollset_set *pollset_set, - const struct sockaddr *addr, int addr_len, gpr_timespec deadline, - const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, - grpc_transport **transport, grpc_iomgr_closure *notify) { - connector->vtable->connect(connector, pollset_set, addr, addr_len, deadline, - channel_args, metadata_context, transport, notify); + grpc_connector *connector, + const grpc_connect_in_args *in_args, + grpc_connect_out_args *out_args, + grpc_iomgr_closure *notify) { + connector->vtable->connect(connector, in_args, out_args, notify); } diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h index 72414377293..55c6e63129a 100644 --- a/src/core/client_config/connector.h +++ b/src/core/client_config/connector.h @@ -34,6 +34,7 @@ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H +#include "src/core/channel/channel_stack.h" #include "src/core/iomgr/sockaddr.h" #include "src/core/transport/transport.h" @@ -44,22 +45,43 @@ struct grpc_connector { const grpc_connector_vtable *vtable; }; +typedef struct { + /** set of pollsets interested in this connection */ + grpc_pollset_set *interested_parties; + /** address to connect to */ + const struct sockaddr *addr; + int addr_len; + /** deadline for connection */ + gpr_timespec deadline; + /** channel arguments (to be passed to transport) */ + const grpc_channel_args *channel_args; + /** metadata context */ + grpc_mdctx *metadata_context; +} grpc_connect_in_args; + +typedef struct { + /** the connected transport */ + grpc_transport *transport; + /** any additional filters (owned by the caller of connect) */ + const grpc_channel_filter **filters; + size_t num_filters; +} grpc_connect_out_args; + struct grpc_connector_vtable { void (*ref)(grpc_connector *connector); void (*unref)(grpc_connector *connector); - void (*connect)(grpc_connector *connector, grpc_pollset_set *pollset_set, - const struct sockaddr *addr, int addr_len, - gpr_timespec deadline, const grpc_channel_args *channel_args, - grpc_mdctx *metadata_context, grpc_transport **transport, + void (*connect)(grpc_connector *connector, + const grpc_connect_in_args *in_args, + grpc_connect_out_args *out_args, grpc_iomgr_closure *notify); }; void grpc_connector_ref(grpc_connector *connector); void grpc_connector_unref(grpc_connector *connector); void grpc_connector_connect( - grpc_connector *connector, grpc_pollset_set *pollset_set, - const struct sockaddr *addr, int addr_len, gpr_timespec deadline, - const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, - grpc_transport **transport, grpc_iomgr_closure *notify); + grpc_connector *connector, + const grpc_connect_in_args *in_args, + grpc_connect_out_args *out_args, + grpc_iomgr_closure *notify); #endif diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index e863c5b97cc..c2044c9e706 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -74,7 +74,7 @@ struct grpc_subchannel { grpc_mdctx *mdctx; /** set during connection */ - grpc_transport *connecting_transport; + grpc_connect_out_args connecting_result; /** callback for connection finishing */ grpc_iomgr_closure connected; @@ -101,7 +101,8 @@ struct grpc_subchannel_call { gpr_refcount refs; }; -#define SUBCHANNEL_CALL_TO_CALL_STACK(call) (((grpc_call_stack *)(call)) + 1) +#define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack *)((call) + 1)) +#define CHANNEL_STACK_FROM_CONNECTION(con) ((grpc_channel_stack *)((con) + 1)) static grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op); static void connectivity_state_changed_locked(grpc_subchannel *c); @@ -160,6 +161,19 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, return c; } +static void start_connect(grpc_subchannel *c) { + grpc_connect_in_args args; + + args.interested_parties = &c->pollset_set; + args.addr = c->addr; + args.addr_len = c->addr_len; + args.deadline = compute_connect_deadline(c); + args.channel_args = c->args; + args.metadata_context = c->mdctx; + + grpc_connector_connect(c->connector, &args, &c->connecting_result, &c->connected); +} + void grpc_subchannel_create_call(grpc_subchannel *c, grpc_transport_stream_op *initial_op, grpc_subchannel_call **target, @@ -187,9 +201,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, grpc_subchannel_ref(c); gpr_mu_unlock(&c->mu); - grpc_connector_connect(c->connector, &c->pollset_set, c->addr, - c->addr_len, compute_connect_deadline(c), c->args, - c->mdctx, &c->connecting_transport, &c->connected); + start_connect(c); } else { gpr_mu_unlock(&c->mu); } @@ -232,9 +244,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, gpr_mu_unlock(&c->mu); } if (do_connect) { - grpc_connector_connect(c->connector, &c->pollset_set, c->addr, c->addr_len, - compute_connect_deadline(c), c->args, c->mdctx, - &c->connecting_transport, &c->connected); + start_connect(c); } } @@ -246,8 +256,8 @@ static void publish_transport(grpc_subchannel *c) { gpr_ref_init(&con->refs, 1); con->subchannel = c; grpc_channel_stack_init(c->filters, c->filter_count, c->args, c->mdctx, stk); - grpc_connected_channel_bind_transport(stk, c->connecting_transport); - c->connecting_transport = NULL; + grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); + memset(&c->connecting_result, 0, sizeof(c->connecting_result)); gpr_mu_lock(&c->mu); GPR_ASSERT(c->active == NULL); @@ -262,7 +272,7 @@ static void publish_transport(grpc_subchannel *c) { static void subchannel_connected(void *arg, int iomgr_success) { grpc_subchannel *c = arg; - if (c->connecting_transport) { + if (c->connecting_result.transport) { publish_transport(c); } else { grpc_subchannel_unref(c); @@ -330,6 +340,11 @@ void grpc_subchannel_call_process_op(grpc_subchannel_call *call, } grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op) { - abort(); - return NULL; + grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con); + grpc_subchannel_call *call = gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size); + grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(call); + call->connection = con; + gpr_ref_init(&call->refs, 1); + grpc_call_stack_init(chanstk, NULL, initial_op, callstk); + return call; } diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 3d54ff58d82..afa1d36820c 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -49,10 +49,9 @@ typedef struct { grpc_connector base; gpr_refcount refs; - grpc_transport **transport; grpc_iomgr_closure *notify; - const grpc_channel_args *args; - grpc_mdctx *mdctx; + grpc_connect_in_args args; + grpc_connect_out_args *result; } connector; static void connector_ref(grpc_connector *con) { @@ -71,10 +70,10 @@ static void connected(void *arg, grpc_endpoint *tcp) { connector *c = arg; grpc_iomgr_closure *notify; if (tcp != NULL) { - *c->transport = - grpc_create_chttp2_transport(c->args, tcp, NULL, 0, c->mdctx, 1); + c->result->transport = + grpc_create_chttp2_transport(c->args.channel_args, tcp, NULL, 0, c->args.metadata_context, 1); } else { - *c->transport = NULL; + c->result->transport = NULL; } notify = c->notify; c->notify = NULL; @@ -82,18 +81,15 @@ static void connected(void *arg, grpc_endpoint *tcp) { } static void connector_connect( - grpc_connector *con, grpc_pollset_set *pollset_set, - const struct sockaddr *addr, int addr_len, gpr_timespec deadline, - const grpc_channel_args *channel_args, grpc_mdctx *metadata_context, - grpc_transport **transport, grpc_iomgr_closure *notify) { + grpc_connector *con, const grpc_connect_in_args *args, + grpc_connect_out_args *result, grpc_iomgr_closure *notify) { connector *c = (connector *)con; GPR_ASSERT(c->notify == NULL); GPR_ASSERT(notify->cb); c->notify = notify; - c->args = channel_args; - c->mdctx = metadata_context; - c->transport = transport; - grpc_tcp_client_connect(connected, c, pollset_set, addr, addr_len, deadline); + c->args = *args; + c->result = result; + grpc_tcp_client_connect(connected, c, args->interested_parties, args->addr, args->addr_len, args->deadline); } static const grpc_connector_vtable connector_vtable = {connector_ref, connector_unref, connector_connect}; diff --git a/src/core/surface/server.c b/src/core/surface/server.c index f4d76e882fa..6d06725bf3a 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -1229,6 +1229,8 @@ static void begin_call(grpc_server *server, call_data *calld, calld->cq_new = rc->cq_for_notification; switch (rc->type) { case BATCH_CALL: + GPR_ASSERT(calld->host != NULL); + GPR_ASSERT(calld->path != NULL); cpstr(&rc->data.batch.details->host, &rc->data.batch.details->host_capacity, calld->host); cpstr(&rc->data.batch.details->method, From 5945ee1a75083777ddd8fe4f49531f6f3e307d7a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sat, 27 Jun 2015 10:36:09 -0700 Subject: [PATCH 046/124] Request/response path starting to work --- src/core/channel/http_client_filter.c | 1 - src/core/client_config/subchannel.c | 32 +++++++++++++++++++-------- src/core/surface/channel_create.c | 6 ++++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index 6928a59c38a..5dec734c8cd 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -179,7 +179,6 @@ static void init_channel_elem(grpc_channel_element *elem, /* The first and the last filters tend to be implemented differently to handle the case that there's no 'next' filter to call on the up or down path */ - GPR_ASSERT(!is_first); GPR_ASSERT(!is_last); /* initialize members */ diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index c2044c9e706..b489ce04a5d 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -64,7 +64,7 @@ struct grpc_subchannel { /** non-transport related channel filters */ const grpc_channel_filter **filters; - size_t filter_count; + size_t num_filters; /** channel arguments */ grpc_channel_args *args; /** address to connect to */ @@ -144,11 +144,10 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, gpr_ref_init(&c->refs, 1); c->connector = connector; grpc_connector_ref(c->connector); - c->filter_count = args->filter_count + 1; - c->filters = gpr_malloc(sizeof(grpc_channel_filter *) * c->filter_count); + c->num_filters = args->filter_count; + c->filters = gpr_malloc(sizeof(grpc_channel_filter *) * c->num_filters); memcpy(c->filters, args->filters, - sizeof(grpc_channel_filter *) * args->filter_count); - c->filters[c->filter_count - 1] = &grpc_connected_channel_filter; + sizeof(grpc_channel_filter *) * c->num_filters); c->addr = gpr_malloc(args->addr_len); memcpy(c->addr, args->addr, args->addr_len); c->addr_len = args->addr_len; @@ -249,13 +248,26 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, } static void publish_transport(grpc_subchannel *c) { - size_t channel_stack_size = grpc_channel_stack_size(c->filters, c->filter_count); - connection *con = gpr_malloc(sizeof(connection) + channel_stack_size); - grpc_channel_stack *stk = (grpc_channel_stack *)(con + 1); + size_t channel_stack_size; + connection *con; + grpc_channel_stack *stk; + size_t num_filters; + const grpc_channel_filter **filters; waiting_for_connect *w4c; + + num_filters = c->num_filters + c->connecting_result.num_filters + 1; + filters = gpr_malloc(sizeof(*filters) * num_filters); + memcpy(filters, c->filters, sizeof(*filters) * c->num_filters); + memcpy(filters + c->num_filters, c->connecting_result.filters, sizeof(*filters) * c->connecting_result.num_filters); + filters[num_filters - 1] = &grpc_connected_channel_filter; + + channel_stack_size = grpc_channel_stack_size(filters, num_filters); + con = gpr_malloc(sizeof(connection) + channel_stack_size); + stk = (grpc_channel_stack *)(con + 1); + gpr_ref_init(&con->refs, 1); con->subchannel = c; - grpc_channel_stack_init(c->filters, c->filter_count, c->args, c->mdctx, stk); + grpc_channel_stack_init(filters, num_filters, c->args, c->mdctx, stk); grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); memset(&c->connecting_result, 0, sizeof(c->connecting_result)); @@ -268,6 +280,8 @@ static void publish_transport(grpc_subchannel *c) { abort(); /* not implemented */ } gpr_mu_unlock(&c->mu); + + gpr_free(filters); } static void subchannel_connected(void *arg, int iomgr_success) { diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index afa1d36820c..a00c08a8300 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -40,6 +40,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/client_channel.h" +#include "src/core/channel/http_client_filter.h" #include "src/core/client_config/resolver_registry.h" #include "src/core/iomgr/tcp_client.h" #include "src/core/surface/channel.h" @@ -72,8 +73,11 @@ static void connected(void *arg, grpc_endpoint *tcp) { if (tcp != NULL) { c->result->transport = grpc_create_chttp2_transport(c->args.channel_args, tcp, NULL, 0, c->args.metadata_context, 1); + c->result->filters = gpr_malloc(sizeof(grpc_channel_filter*)); + c->result->filters[0] = &grpc_http_client_filter; + c->result->num_filters = 1; } else { - c->result->transport = NULL; + memset(c->result, 0, sizeof(*c->result)); } notify = c->notify; c->notify = NULL; From 7874e17d77f262f682a88f38ca24cf9a7b45542f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sat, 27 Jun 2015 10:49:37 -0700 Subject: [PATCH 047/124] Implement channel op dispatch --- src/core/surface/channel.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 6c4b407a850..8c136af8412 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -237,8 +237,19 @@ void grpc_channel_internal_unref(grpc_channel *channel) { } } +static void default_consumed(void *arg, int iomgr_success) { + grpc_channel *channel = arg; + GRPC_CHANNEL_INTERNAL_UNREF(channel, "op"); +} + static void execute_op(grpc_channel *channel, grpc_transport_op *op) { - abort(); + grpc_channel_element *elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0); + if (op->on_consumed == NULL) { + GRPC_CHANNEL_INTERNAL_REF(channel, "op"); + op->on_consumed = gpr_malloc(sizeof(*op->on_consumed)); + grpc_iomgr_closure_init(op->on_consumed, default_consumed, channel); + } + elem->filter->start_transport_op(elem, op); } void grpc_channel_destroy(grpc_channel *channel) { From c7b5f7605e7210e2bfa1915f585a9ccfa44bbb30 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sat, 27 Jun 2015 11:48:42 -0700 Subject: [PATCH 048/124] Factor out channel state watching --- BUILD | 40 ++++- Makefile | 2 + build.json | 2 + gRPC.podspec | 3 + src/core/channel/client_channel.c | 166 ------------------ src/core/channel/connectivity_state.c | 92 ++++++++++ src/core/channel/connectivity_state.h | 66 +++++++ .../client_config/lb_policies/pick_first.c | 44 ++++- src/core/client_config/lb_policy.h | 10 ++ src/core/client_config/subchannel.c | 58 ++---- src/core/client_config/subchannel.h | 15 +- tools/doxygen/Doxyfile.core.internal | 2 + tools/run_tests/sources_and_headers.json | 120 +++++++++++-- vsprojects/grpc/grpc.vcxproj | 3 + vsprojects/grpc/grpc.vcxproj.filters | 6 + .../grpc_unsecure/grpc_unsecure.vcxproj | 3 + .../grpc_unsecure.vcxproj.filters | 6 + 17 files changed, 398 insertions(+), 240 deletions(-) create mode 100644 src/core/channel/connectivity_state.c create mode 100644 src/core/channel/connectivity_state.h diff --git a/BUILD b/BUILD index af2712549c0..201d8449c88 100644 --- a/BUILD +++ b/BUILD @@ -152,6 +152,7 @@ cc_library( "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -268,6 +269,7 @@ cc_library( "src/core/channel/channel_stack.c", "src/core/channel/client_channel.c", "src/core/channel/connected_channel.c", + "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", @@ -400,6 +402,7 @@ cc_library( "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -494,6 +497,7 @@ cc_library( "src/core/channel/channel_stack.c", "src/core/channel/client_channel.c", "src/core/channel/connected_channel.c", + "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", @@ -930,13 +934,23 @@ objc_library( "src/core/census/grpc_context.c", "src/core/channel/channel_args.c", "src/core/channel/channel_stack.c", - "src/core/channel/child_channel.c", "src/core/channel/client_channel.c", - "src/core/channel/client_setup.c", "src/core/channel/connected_channel.c", + "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", + "src/core/client_config/client_config.c", + "src/core/client_config/connector.c", + "src/core/client_config/lb_policies/pick_first.c", + "src/core/client_config/lb_policy.c", + "src/core/client_config/resolver.c", + "src/core/client_config/resolver_factory.c", + "src/core/client_config/resolver_registry.c", + "src/core/client_config/resolvers/dns_resolver.c", + "src/core/client_config/subchannel.c", + "src/core/client_config/subchannel_factory.c", + "src/core/client_config/uri_parser.c", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/debug/trace.c", @@ -989,7 +1003,6 @@ objc_library( "src/core/surface/call_log_batch.c", "src/core/surface/channel.c", "src/core/surface/channel_create.c", - "src/core/surface/client.c", "src/core/surface/completion_queue.c", "src/core/surface/event_string.c", "src/core/surface/init.c", @@ -1010,11 +1023,15 @@ objc_library( "src/core/transport/chttp2/hpack_parser.c", "src/core/transport/chttp2/hpack_table.c", "src/core/transport/chttp2/huffsyms.c", + "src/core/transport/chttp2/incoming_metadata.c", + "src/core/transport/chttp2/parsing.c", "src/core/transport/chttp2/status_conversion.c", "src/core/transport/chttp2/stream_encoder.c", + "src/core/transport/chttp2/stream_lists.c", "src/core/transport/chttp2/stream_map.c", "src/core/transport/chttp2/timeout_encoding.c", "src/core/transport/chttp2/varint.c", + "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", "src/core/transport/metadata.c", "src/core/transport/stream_op.c", @@ -1034,14 +1051,24 @@ objc_library( "src/core/channel/census_filter.h", "src/core/channel/channel_args.h", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.h", + "src/core/client_config/connector.h", + "src/core/client_config/lb_policies/pick_first.h", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.h", + "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -1084,7 +1111,6 @@ objc_library( "src/core/surface/byte_buffer_queue.h", "src/core/surface/call.h", "src/core/surface/channel.h", - "src/core/surface/client.h", "src/core/surface/completion_queue.h", "src/core/surface/event_string.h", "src/core/surface/init.h", @@ -1103,6 +1129,8 @@ objc_library( "src/core/transport/chttp2/hpack_table.h", "src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/huffsyms.h", + "src/core/transport/chttp2/incoming_metadata.h", + "src/core/transport/chttp2/internal.h", "src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/stream_encoder.h", "src/core/transport/chttp2/stream_map.h", diff --git a/Makefile b/Makefile index 766db0c2d89..ff8a41598f1 100644 --- a/Makefile +++ b/Makefile @@ -3018,6 +3018,7 @@ LIBGRPC_SRC = \ src/core/channel/channel_stack.c \ src/core/channel/client_channel.c \ src/core/channel/connected_channel.c \ + src/core/channel/connectivity_state.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ @@ -3276,6 +3277,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/channel/channel_stack.c \ src/core/channel/client_channel.c \ src/core/channel/connected_channel.c \ + src/core/channel/connectivity_state.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ diff --git a/build.json b/build.json index c4f02423885..7893ea3d0f9 100644 --- a/build.json +++ b/build.json @@ -113,6 +113,7 @@ "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -207,6 +208,7 @@ "src/core/channel/channel_stack.c", "src/core/channel/client_channel.c", "src/core/channel/connected_channel.c", + "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", diff --git a/gRPC.podspec b/gRPC.podspec index 862c24b27e7..4cc71e3cf1b 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -154,6 +154,7 @@ Pod::Spec.new do |s| 'src/core/channel/channel_stack.h', 'src/core/channel/client_channel.h', 'src/core/channel/connected_channel.h', + 'src/core/channel/connectivity_state.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', @@ -277,6 +278,7 @@ Pod::Spec.new do |s| 'src/core/channel/channel_stack.c', 'src/core/channel/client_channel.c', 'src/core/channel/connected_channel.c', + 'src/core/channel/connectivity_state.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', @@ -408,6 +410,7 @@ Pod::Spec.new do |s| 'src/core/channel/channel_stack.h', 'src/core/channel/client_channel.h', 'src/core/channel/connected_channel.h', + 'src/core/channel/connectivity_state.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index dc838de7153..4d082aceb86 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -426,88 +426,6 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { } } -#if 0 -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - channel_data *chand = elem->channel_data; - grpc_child_channel *child_channel; - grpc_channel_op rop; - GPR_ASSERT(elem->filter == &grpc_client_channel_filter); - - switch (op->type) { - case GRPC_CHANNEL_GOAWAY: - /* sending goaway: clear out the active child on the way through */ - gpr_mu_lock(&chand->mu); - child_channel = chand->active_child; - chand->active_child = NULL; - gpr_mu_unlock(&chand->mu); - if (child_channel) { - grpc_child_channel_handle_op(child_channel, op); - grpc_child_channel_destroy(child_channel, 1); - } else { - gpr_slice_unref(op->data.goaway.message); - } - break; - case GRPC_CHANNEL_DISCONNECT: - /* sending disconnect: clear out the active child on the way through */ - gpr_mu_lock(&chand->mu); - child_channel = chand->active_child; - chand->active_child = NULL; - gpr_mu_unlock(&chand->mu); - if (child_channel) { - grpc_child_channel_destroy(child_channel, 1); - } - /* fake a transport closed to satisfy the refcounting in client */ - rop.type = GRPC_TRANSPORT_CLOSED; - rop.dir = GRPC_CALL_UP; - grpc_channel_next_op(elem, &rop); - break; - case GRPC_TRANSPORT_GOAWAY: - /* receiving goaway: if it's from our active child, drop the active child; - in all cases consume the event here */ - gpr_mu_lock(&chand->mu); - child_channel = grpc_channel_stack_from_top_element(from_elem); - if (child_channel == chand->active_child) { - chand->active_child = NULL; - } else { - child_channel = NULL; - } - gpr_mu_unlock(&chand->mu); - if (child_channel) { - grpc_child_channel_destroy(child_channel, 0); - } - gpr_slice_unref(op->data.goaway.message); - break; - case GRPC_TRANSPORT_CLOSED: - /* receiving disconnect: if it's from our active child, drop the active - child; in all cases consume the event here */ - gpr_mu_lock(&chand->mu); - child_channel = grpc_channel_stack_from_top_element(from_elem); - if (child_channel == chand->active_child) { - chand->active_child = NULL; - } else { - child_channel = NULL; - } - gpr_mu_unlock(&chand->mu); - if (child_channel) { - grpc_child_channel_destroy(child_channel, 0); - } - break; - default: - switch (op->dir) { - case GRPC_CALL_UP: - grpc_channel_next_op(elem, op); - break; - case GRPC_CALL_DOWN: - gpr_log(GPR_ERROR, "unhandled channel op: %d", op->type); - abort(); - break; - } - break; - } -} -#endif - static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op *op) {} /* Constructor for call_data */ @@ -591,90 +509,6 @@ const grpc_channel_filter grpc_client_channel_filter = { init_channel_elem, destroy_channel_elem, "client-channel", }; -#if 0 -grpc_transport_setup_result grpc_client_channel_transport_setup_complete( - grpc_channel_stack *channel_stack, grpc_transport *transport, - grpc_channel_filter const **channel_filters, size_t num_channel_filters, - grpc_mdctx *mdctx) { - /* we just got a new transport: lets create a child channel stack for it */ - grpc_channel_element *elem = grpc_channel_stack_last_element(channel_stack); - channel_data *chand = elem->channel_data; - size_t num_child_filters = 2 + num_channel_filters; - grpc_channel_filter const **child_filters; - grpc_transport_setup_result result; - grpc_child_channel *old_active = NULL; - call_data **waiting_children; - size_t waiting_child_count; - size_t i; - grpc_transport_stream_op *call_ops; - - /* build the child filter stack */ - child_filters = gpr_malloc(sizeof(grpc_channel_filter *) * num_child_filters); - /* we always need a link back filter to get back to the connected channel */ - child_filters[0] = &grpc_child_channel_top_filter; - for (i = 0; i < num_channel_filters; i++) { - child_filters[i + 1] = channel_filters[i]; - } - /* and we always need a connected channel to talk to the transport */ - child_filters[num_child_filters - 1] = &grpc_connected_channel_filter; - - GPR_ASSERT(elem->filter == &grpc_client_channel_filter); - - /* BEGIN LOCKING CHANNEL */ - gpr_mu_lock(&chand->mu); - chand->transport_setup_initiated = 0; - - if (chand->active_child) { - old_active = chand->active_child; - } - chand->active_child = grpc_child_channel_create( - elem, child_filters, num_child_filters, chand->args, mdctx); - result = - grpc_connected_channel_bind_transport(chand->active_child, transport); - - /* capture the waiting children - we'll activate them outside the lock - to avoid re-entrancy problems */ - waiting_children = chand->waiting_children; - waiting_child_count = chand->waiting_child_count; - /* bumping up inflight_requests here avoids taking a lock per rpc below */ - - chand->waiting_children = NULL; - chand->waiting_child_count = 0; - chand->waiting_child_capacity = 0; - - call_ops = gpr_malloc(sizeof(*call_ops) * waiting_child_count); - - for (i = 0; i < waiting_child_count; i++) { - call_ops[i] = waiting_children[i]->waiting_op; - if (!prepare_activate(waiting_children[i]->elem, chand->active_child)) { - waiting_children[i] = NULL; - grpc_transport_stream_op_finish_with_failure(&call_ops[i]); - } - } - - /* END LOCKING CHANNEL */ - gpr_mu_unlock(&chand->mu); - - /* activate any pending operations - this is safe to do as we guarantee one - and only one write operation per request at the surface api - if we lose - that guarantee we need to do some curly locking here */ - for (i = 0; i < waiting_child_count; i++) { - if (waiting_children[i]) { - complete_activate(waiting_children[i]->elem, &call_ops[i]); - } - } - gpr_free(waiting_children); - gpr_free(call_ops); - gpr_free(child_filters); - - if (old_active) { - grpc_child_channel_destroy(old_active, 1); - } - - return result; -} -#endif - void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, grpc_resolver *resolver) { /* post construction initialization: set the transport setup pointer */ diff --git a/src/core/channel/connectivity_state.c b/src/core/channel/connectivity_state.c new file mode 100644 index 00000000000..566a2c33449 --- /dev/null +++ b/src/core/channel/connectivity_state.c @@ -0,0 +1,92 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/channel/connectivity_state.h" +#include + +void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state init_state) { + tracker->current_state = init_state; + tracker->watchers = NULL; +} + +void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker) { + grpc_connectivity_state_watcher *w; + while ((w = tracker->watchers)) { + tracker->watchers = w->next; + + if (GRPC_CHANNEL_FATAL_FAILURE != *w->current) { + *w->current = GRPC_CHANNEL_FATAL_FAILURE; + grpc_iomgr_add_callback(w->notify); + } else { + grpc_iomgr_add_delayed_callback(w->notify, 0); + } + gpr_free(w); + } +} + +grpc_connectivity_state grpc_connectivity_state_check(grpc_connectivity_state_tracker *tracker) { + return tracker->current_state; +} + +int grpc_connectivity_state_notify_on_state_change(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, grpc_iomgr_closure *notify) { + if (tracker->current_state != *current) { + *current = tracker->current_state; + grpc_iomgr_add_callback(notify); + } else { + grpc_connectivity_state_watcher *w = gpr_malloc(sizeof(*w)); + w->current = current; + w->notify = notify; + w->next = tracker->watchers; + tracker->watchers = w; + } + return tracker->current_state == GRPC_CHANNEL_IDLE; +} + +void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state) { + grpc_connectivity_state_watcher *new = NULL; + grpc_connectivity_state_watcher *w; + tracker->current_state = state; + while ((w = tracker->watchers)) { + tracker->watchers = w->next; + + if (state != *w->current) { + *w->current = state; + grpc_iomgr_add_callback(w->notify); + gpr_free(w); + } else { + w->next = new; + new = w; + } + } + tracker->watchers = new; +} diff --git a/src/core/channel/connectivity_state.h b/src/core/channel/connectivity_state.h new file mode 100644 index 00000000000..ebc1acc5592 --- /dev/null +++ b/src/core/channel/connectivity_state.h @@ -0,0 +1,66 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CONNECTIVITY_STATE_H +#define GRPC_INTERNAL_CORE_CHANNEL_CONNECTIVITY_STATE_H + +#include +#include "src/core/iomgr/iomgr.h" + +typedef struct grpc_connectivity_state_watcher { + /** we keep watchers in a linked list */ + struct grpc_connectivity_state_watcher *next; + /** closure to notify on change */ + grpc_iomgr_closure *notify; + /** the current state as believed by the watcher */ + grpc_connectivity_state *current; +} grpc_connectivity_state_watcher; + +typedef struct { + /** current connectivity state */ + grpc_connectivity_state current_state; + /** all our watchers */ + grpc_connectivity_state_watcher *watchers; +} grpc_connectivity_state_tracker; + +void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state init_state); +void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker); + +void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state); + +grpc_connectivity_state grpc_connectivity_state_check(grpc_connectivity_state_tracker *tracker); + +/** Return 1 if the channel should start connecting, 0 otherwise */ +int grpc_connectivity_state_notify_on_state_change(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, grpc_iomgr_closure *notify); + +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONNECTIVITY_STATE_H */ diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index f3a6d21eb56..4fda07a63fe 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -36,6 +36,7 @@ #include #include +#include "src/core/channel/connectivity_state.h" typedef struct pending_pick { struct pending_pick *next; @@ -69,6 +70,9 @@ typedef struct { grpc_connectivity_state checking_connectivity; /** list of picks that are waiting on connectivity */ pending_pick *pending_picks; + + /** our connectivity state tracker */ + grpc_connectivity_state_tracker state_tracker; } pick_first_lb_policy; void pf_ref(grpc_lb_policy *pol) { @@ -184,8 +188,46 @@ loop: } } +static void pf_broadcast(grpc_lb_policy *pol, grpc_transport_op *op) { + pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + size_t i; + size_t n; + grpc_subchannel **subchannels; + + gpr_mu_lock(&p->mu); + n = p->num_subchannels; + subchannels = gpr_malloc(n * sizeof(*subchannels)); + for (i = 0; i < n; i++) { + subchannels[i] = p->subchannels[i]; + grpc_subchannel_ref(subchannels[i]); + } + gpr_mu_unlock(&p->mu); + + for (i = 0; i < n; i++) { + grpc_subchannel_process_transport_op(subchannels[i], op); + grpc_subchannel_unref(subchannels[i]); + } + gpr_free(subchannels); +} + +static grpc_connectivity_state pf_check_connectivity(grpc_lb_policy *pol) { + pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + grpc_connectivity_state st; + gpr_mu_lock(&p->mu); + st = grpc_connectivity_state_check(&p->state_tracker); + gpr_mu_unlock(&p->mu); + return st; +} + +static void pf_notify_on_state_change(grpc_lb_policy *pol, grpc_connectivity_state *current, grpc_iomgr_closure *notify) { + pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + gpr_mu_lock(&p->mu); + grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current, notify); + gpr_mu_unlock(&p->mu); +} + static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = { - pf_ref, pf_unref, pf_shutdown, pf_pick}; + pf_ref, pf_unref, pf_shutdown, pf_pick, pf_broadcast, pf_check_connectivity, pf_notify_on_state_change}; grpc_lb_policy *grpc_create_pick_first_lb_policy(grpc_subchannel **subchannels, size_t num_subchannels) { diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 42929e933b3..42be9152cba 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -58,6 +58,16 @@ struct grpc_lb_policy_vtable { void (*pick)(grpc_lb_policy *policy, grpc_pollset *pollset, grpc_metadata_batch *initial_metadata, grpc_subchannel **target, grpc_iomgr_closure *on_complete); + + /** broadcast a transport op to all subchannels */ + void (*broadcast)(grpc_lb_policy *policy, grpc_transport_op *op); + + /** check the current connectivity of the lb_policy */ + grpc_connectivity_state (*check_connectivity)(grpc_lb_policy *policy); + + /** call notify when the connectivity state of a channel changes from *state. + Updates *state with the new state of the policy */ + void (*notify_on_state_change)(grpc_lb_policy *policy, grpc_connectivity_state *state, grpc_iomgr_closure *closure); }; void grpc_lb_policy_ref(grpc_lb_policy *policy); diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index b489ce04a5d..5cbb5d99716 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -39,6 +39,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/connected_channel.h" +#include "src/core/channel/connectivity_state.h" typedef struct { gpr_refcount refs; @@ -52,12 +53,6 @@ typedef struct waiting_for_connect { grpc_subchannel_call **target; } waiting_for_connect; -typedef struct connectivity_state_watcher { - struct connectivity_state_watcher *next; - grpc_iomgr_closure *notify; - grpc_connectivity_state *current; -} connectivity_state_watcher; - struct grpc_subchannel { gpr_refcount refs; grpc_connector *connector; @@ -92,8 +87,8 @@ struct grpc_subchannel { int connecting; /** things waiting for a connection */ waiting_for_connect *waiting; - /** things watching the connectivity state */ - connectivity_state_watcher *watchers; + /** connectivity state tracking */ + grpc_connectivity_state_tracker state_tracker; }; struct grpc_subchannel_call { @@ -123,6 +118,7 @@ void grpc_subchannel_unref(grpc_subchannel *c) { gpr_free(c->addr); grpc_mdctx_unref(c->mdctx); grpc_pollset_set_destroy(&c->pollset_set); + grpc_connectivity_state_destroy(&c->state_tracker); gpr_free(c); } } @@ -156,6 +152,7 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, grpc_mdctx_ref(c->mdctx); grpc_pollset_set_init(&c->pollset_set); grpc_iomgr_closure_init(&c->connected, subchannel_connected, c); + grpc_connectivity_state_init(&c->state_tracker, GRPC_CHANNEL_IDLE); gpr_mu_init(&c->mu); return c; } @@ -210,7 +207,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel *c) { grpc_connectivity_state state; gpr_mu_lock(&c->mu); - state = compute_connectivity_locked(c); + state = grpc_connectivity_state_check(&c->state_tracker); gpr_mu_unlock(&c->mu); return state; } @@ -218,35 +215,24 @@ grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel *c) { void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, grpc_connectivity_state *state, grpc_iomgr_closure *notify) { - grpc_connectivity_state current; int do_connect = 0; - connectivity_state_watcher *w = gpr_malloc(sizeof(*w)); - w->current = state; - w->notify = notify; gpr_mu_lock(&c->mu); - current = compute_connectivity_locked(c); - if (current == GRPC_CHANNEL_IDLE) { - current = GRPC_CHANNEL_CONNECTING; + if (grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state, notify)) { + do_connect = 1; c->connecting = 1; - do_connect = 1; grpc_subchannel_ref(c); - connectivity_state_changed_locked(c); - } - if (current != *state) { - gpr_mu_unlock(&c->mu); - *state = current; - grpc_iomgr_add_callback(notify); - gpr_free(w); - } else { - w->next = c->watchers; - c->watchers = w; - gpr_mu_unlock(&c->mu); + grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); } + gpr_mu_unlock(&c->mu); if (do_connect) { start_connect(c); } } +void grpc_subchannel_process_transport_op(grpc_subchannel *c, grpc_transport_op *op) { + abort(); +} + static void publish_transport(grpc_subchannel *c) { size_t channel_stack_size; connection *con; @@ -311,21 +297,7 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { static void connectivity_state_changed_locked(grpc_subchannel *c) { grpc_connectivity_state current = compute_connectivity_locked(c); - connectivity_state_watcher *new = NULL; - connectivity_state_watcher *w; - while ((w = c->watchers)) { - c->watchers = w->next; - - if (current != *w->current) { - *w->current = current; - grpc_iomgr_add_callback(w->notify); - gpr_free(w); - } else { - w->next = new; - new = w; - } - } - c->watchers = new; + grpc_connectivity_state_set(&c->state_tracker, current); } /* diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 8836f9b09c1..60b95d3d8fc 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -46,6 +46,15 @@ typedef struct grpc_subchannel_args grpc_subchannel_args; void grpc_subchannel_ref(grpc_subchannel *channel); void grpc_subchannel_unref(grpc_subchannel *channel); +/** construct a call (possibly asynchronously) */ +void grpc_subchannel_create_call(grpc_subchannel *subchannel, + grpc_transport_stream_op *initial_op, + grpc_subchannel_call **target, + grpc_iomgr_closure *notify); + +/** process a transport level op */ +void grpc_subchannel_process_transport_op(grpc_subchannel *subchannel, grpc_transport_op *op); + void grpc_subchannel_call_ref(grpc_subchannel_call *call); void grpc_subchannel_call_unref(grpc_subchannel_call *call); @@ -62,12 +71,6 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, void grpc_subchannel_add_interested_party(grpc_subchannel *channel, grpc_pollset *pollset); void grpc_subchannel_del_interested_party(grpc_subchannel *channel, grpc_pollset *pollset); -/** construct a call (possibly asynchronously) */ -void grpc_subchannel_create_call(grpc_subchannel *subchannel, - grpc_transport_stream_op *initial_op, - grpc_subchannel_call **target, - grpc_iomgr_closure *notify); - /** continue processing a transport op */ void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, grpc_transport_stream_op *op); diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 56af4ce3126..edc7c5d6fe7 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -789,6 +789,7 @@ src/core/channel/channel_args.h \ src/core/channel/channel_stack.h \ src/core/channel/client_channel.h \ src/core/channel/connected_channel.h \ +src/core/channel/connectivity_state.h \ src/core/channel/context.h \ src/core/channel/http_client_filter.h \ src/core/channel/http_server_filter.h \ @@ -905,6 +906,7 @@ src/core/channel/channel_args.c \ src/core/channel/channel_stack.c \ src/core/channel/client_channel.c \ src/core/channel/connected_channel.c \ +src/core/channel/connectivity_state.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 5c74bf1eea3..8dab263d7a6 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -931,6 +931,20 @@ "test/core/tsi/transport_security_test.c" ] }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc_test_util" + ], + "headers": [], + "language": "c", + "name": "uri_parser_test", + "src": [ + "test/core/client_config/uri_parser_test.c" + ] + }, { "deps": [ "gpr", @@ -8636,14 +8650,24 @@ "src/core/channel/census_filter.h", "src/core/channel/channel_args.h", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.h", + "src/core/client_config/connector.h", + "src/core/client_config/lb_policies/pick_first.h", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.h", + "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/httpcli/format_request.h", @@ -8698,7 +8722,6 @@ "src/core/surface/byte_buffer_queue.h", "src/core/surface/call.h", "src/core/surface/channel.h", - "src/core/surface/client.h", "src/core/surface/completion_queue.h", "src/core/surface/event_string.h", "src/core/surface/init.h", @@ -8717,6 +8740,8 @@ "src/core/transport/chttp2/hpack_table.h", "src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/huffsyms.h", + "src/core/transport/chttp2/incoming_metadata.h", + "src/core/transport/chttp2/internal.h", "src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/stream_encoder.h", "src/core/transport/chttp2/stream_map.h", @@ -8752,14 +8777,12 @@ "src/core/channel/channel_args.h", "src/core/channel/channel_stack.c", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.c", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.c", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.c", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.c", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.c", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.h", @@ -8767,6 +8790,28 @@ "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.c", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.c", + "src/core/client_config/client_config.h", + "src/core/client_config/connector.c", + "src/core/client_config/connector.h", + "src/core/client_config/lb_policies/pick_first.c", + "src/core/client_config/lb_policies/pick_first.h", + "src/core/client_config/lb_policy.c", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.c", + "src/core/client_config/resolver.h", + "src/core/client_config/resolver_factory.c", + "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.c", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.c", + "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/subchannel.c", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.c", + "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.c", + "src/core/client_config/uri_parser.h", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/compression/message_compress.h", @@ -8891,8 +8936,6 @@ "src/core/surface/channel.c", "src/core/surface/channel.h", "src/core/surface/channel_create.c", - "src/core/surface/client.c", - "src/core/surface/client.h", "src/core/surface/completion_queue.c", "src/core/surface/completion_queue.h", "src/core/surface/event_string.c", @@ -8933,16 +8976,22 @@ "src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/huffsyms.c", "src/core/transport/chttp2/huffsyms.h", + "src/core/transport/chttp2/incoming_metadata.c", + "src/core/transport/chttp2/incoming_metadata.h", + "src/core/transport/chttp2/internal.h", + "src/core/transport/chttp2/parsing.c", "src/core/transport/chttp2/status_conversion.c", "src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/stream_encoder.c", "src/core/transport/chttp2/stream_encoder.h", + "src/core/transport/chttp2/stream_lists.c", "src/core/transport/chttp2/stream_map.c", "src/core/transport/chttp2/stream_map.h", "src/core/transport/chttp2/timeout_encoding.c", "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/varint.h", + "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", "src/core/transport/chttp2_transport.h", "src/core/transport/metadata.c", @@ -9047,14 +9096,24 @@ "src/core/channel/census_filter.h", "src/core/channel/channel_args.h", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.h", + "src/core/client_config/connector.h", + "src/core/client_config/lb_policies/pick_first.h", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.h", + "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.h", "src/core/compression/message_compress.h", "src/core/debug/trace.h", "src/core/iomgr/alarm.h", @@ -9097,7 +9156,6 @@ "src/core/surface/byte_buffer_queue.h", "src/core/surface/call.h", "src/core/surface/channel.h", - "src/core/surface/client.h", "src/core/surface/completion_queue.h", "src/core/surface/event_string.h", "src/core/surface/init.h", @@ -9116,6 +9174,8 @@ "src/core/transport/chttp2/hpack_table.h", "src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/huffsyms.h", + "src/core/transport/chttp2/incoming_metadata.h", + "src/core/transport/chttp2/internal.h", "src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/stream_encoder.h", "src/core/transport/chttp2/stream_map.h", @@ -9146,14 +9206,12 @@ "src/core/channel/channel_args.h", "src/core/channel/channel_stack.c", "src/core/channel/channel_stack.h", - "src/core/channel/child_channel.c", - "src/core/channel/child_channel.h", "src/core/channel/client_channel.c", "src/core/channel/client_channel.h", - "src/core/channel/client_setup.c", - "src/core/channel/client_setup.h", "src/core/channel/connected_channel.c", "src/core/channel/connected_channel.h", + "src/core/channel/connectivity_state.c", + "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.h", @@ -9161,6 +9219,28 @@ "src/core/channel/http_server_filter.h", "src/core/channel/noop_filter.c", "src/core/channel/noop_filter.h", + "src/core/client_config/client_config.c", + "src/core/client_config/client_config.h", + "src/core/client_config/connector.c", + "src/core/client_config/connector.h", + "src/core/client_config/lb_policies/pick_first.c", + "src/core/client_config/lb_policies/pick_first.h", + "src/core/client_config/lb_policy.c", + "src/core/client_config/lb_policy.h", + "src/core/client_config/resolver.c", + "src/core/client_config/resolver.h", + "src/core/client_config/resolver_factory.c", + "src/core/client_config/resolver_factory.h", + "src/core/client_config/resolver_registry.c", + "src/core/client_config/resolver_registry.h", + "src/core/client_config/resolvers/dns_resolver.c", + "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/subchannel.c", + "src/core/client_config/subchannel.h", + "src/core/client_config/subchannel_factory.c", + "src/core/client_config/subchannel_factory.h", + "src/core/client_config/uri_parser.c", + "src/core/client_config/uri_parser.h", "src/core/compression/algorithm.c", "src/core/compression/message_compress.c", "src/core/compression/message_compress.h", @@ -9255,8 +9335,6 @@ "src/core/surface/channel.c", "src/core/surface/channel.h", "src/core/surface/channel_create.c", - "src/core/surface/client.c", - "src/core/surface/client.h", "src/core/surface/completion_queue.c", "src/core/surface/completion_queue.h", "src/core/surface/event_string.c", @@ -9296,16 +9374,22 @@ "src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/huffsyms.c", "src/core/transport/chttp2/huffsyms.h", + "src/core/transport/chttp2/incoming_metadata.c", + "src/core/transport/chttp2/incoming_metadata.h", + "src/core/transport/chttp2/internal.h", + "src/core/transport/chttp2/parsing.c", "src/core/transport/chttp2/status_conversion.c", "src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/stream_encoder.c", "src/core/transport/chttp2/stream_encoder.h", + "src/core/transport/chttp2/stream_lists.c", "src/core/transport/chttp2/stream_map.c", "src/core/transport/chttp2/stream_map.h", "src/core/transport/chttp2/timeout_encoding.c", "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/varint.h", + "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", "src/core/transport/chttp2_transport.h", "src/core/transport/metadata.c", diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 854443935b8..7354bbc2f6b 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -178,6 +178,7 @@ + @@ -324,6 +325,8 @@ + + diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index 2c02e4a0d85..639fa7093ef 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -85,6 +85,9 @@ src\core\channel + + src\core\channel + src\core\channel @@ -482,6 +485,9 @@ src\core\channel + + src\core\channel + src\core\channel diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index 9080bffff95..6ab4803dbc5 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -160,6 +160,7 @@ + @@ -262,6 +263,8 @@ + + diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index 3861eef863b..a970a728c3f 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -19,6 +19,9 @@ src\core\channel + + src\core\channel + src\core\channel @@ -365,6 +368,9 @@ src\core\channel + + src\core\channel + src\core\channel From ca3e9d3e57a664b63b46d31a22b79a3fe2e3738f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sat, 27 Jun 2015 18:37:27 -0700 Subject: [PATCH 049/124] refcount debugging --- src/core/channel/client_channel.c | 94 +++++++------------ src/core/channel/connectivity_state.c | 3 + .../client_config/lb_policies/pick_first.c | 6 +- src/core/client_config/lb_policy.c | 4 + src/core/client_config/lb_policy.h | 2 + src/core/client_config/subchannel.c | 94 ++++++++++++++++--- src/core/client_config/subchannel.h | 22 ++++- src/core/surface/channel.c | 28 +----- src/core/surface/channel.h | 2 - 9 files changed, 149 insertions(+), 106 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 4d082aceb86..19700a90a6e 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -38,6 +38,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/connected_channel.h" +#include "src/core/channel/connectivity_state.h" #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/pollset_set.h" #include "src/core/support/string.h" @@ -68,8 +69,7 @@ typedef struct { /** resolver callback */ grpc_iomgr_closure on_config_changed; /** connectivity state being tracked */ - grpc_iomgr_closure *on_connectivity_state_change; - grpc_connectivity_state *connectivity_state; + grpc_connectivity_state_tracker state_tracker; } channel_data; typedef enum { @@ -98,60 +98,6 @@ struct call_data { grpc_linked_mdelem details; }; -#if 0 -static int prepare_activate(grpc_call_element *elem, - grpc_child_channel *on_child) { - call_data *calld = elem->call_data; - channel_data *chand = elem->channel_data; - if (calld->state == CALL_CANCELLED) return 0; - - /* no more access to calld->s.waiting allowed */ - GPR_ASSERT(calld->state == CALL_WAITING); - - if (calld->waiting_op.bind_pollset) { - grpc_transport_setup_del_interested_party(chand->transport_setup, - calld->waiting_op.bind_pollset); - } - - calld->state = CALL_ACTIVE; - - /* create a child call */ - /* TODO(ctiller): pass the waiting op down here */ - calld->s.active.child_call = - grpc_child_channel_create_call(on_child, elem, NULL); - - return 1; -} - -static void complete_activate(grpc_call_element *elem, grpc_transport_stream_op *op) { - call_data *calld = elem->call_data; - grpc_call_element *child_elem = - grpc_child_call_get_top_element(calld->s.active.child_call); - - GPR_ASSERT(calld->state == CALL_ACTIVE); - - /* continue the start call down the stack, this nees to happen after metadata - are flushed*/ - child_elem->filter->start_transport_op(child_elem, op); -} - -static void remove_waiting_child(channel_data *chand, call_data *calld) { - size_t new_count; - size_t i; - for (i = 0, new_count = 0; i < chand->waiting_child_count; i++) { - if (chand->waiting_children[i] == calld) { - grpc_transport_setup_del_interested_party( - chand->transport_setup, calld->waiting_op.bind_pollset); - continue; - } - chand->waiting_children[new_count++] = chand->waiting_children[i]; - } - GPR_ASSERT(new_count == chand->waiting_child_count - 1 || - new_count == chand->waiting_child_count); - chand->waiting_child_count = new_count; -} -#endif - static void handle_op_after_cancellation(grpc_call_element *elem, grpc_transport_stream_op *op) { call_data *calld = elem->call_data; @@ -426,7 +372,39 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { } } -static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op *op) {} +static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op *op) { + grpc_lb_policy *lb_policy = NULL; + channel_data *chand = elem->channel_data; + grpc_iomgr_closure *on_consumed = op->on_consumed; + op->on_consumed = NULL; + + GPR_ASSERT(op->set_accept_stream == NULL); + GPR_ASSERT(op->bind_pollset == NULL); + + gpr_mu_lock(&chand->mu_config); + if (op->on_connectivity_state_change != NULL) { + grpc_connectivity_state_notify_on_state_change(&chand->state_tracker, op->connectivity_state, op->on_connectivity_state_change); + op->on_connectivity_state_change = NULL; + op->connectivity_state = NULL; + } + + if (!is_empty(op, sizeof(*op))) { + lb_policy = chand->lb_policy; + if (lb_policy) { + grpc_lb_policy_ref(lb_policy); + } + } + gpr_mu_unlock(&chand->mu_config); + + if (lb_policy) { + grpc_lb_policy_broadcast(lb_policy, op); + grpc_lb_policy_unref(lb_policy); + } + + if (on_consumed) { + grpc_iomgr_add_callback(on_consumed); + } +} /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, @@ -458,7 +436,7 @@ static void destroy_call_elem(grpc_call_element *elem) { case CALL_ACTIVE: subchannel_call = calld->subchannel_call; gpr_mu_unlock(&calld->mu_state); - grpc_subchannel_call_unref(subchannel_call); + GRPC_SUBCHANNEL_CALL_UNREF(subchannel_call, "channel"); break; case CALL_CREATED: case CALL_CANCELLED: diff --git a/src/core/channel/connectivity_state.c b/src/core/channel/connectivity_state.c index 566a2c33449..0ee268ee59a 100644 --- a/src/core/channel/connectivity_state.c +++ b/src/core/channel/connectivity_state.c @@ -75,6 +75,9 @@ int grpc_connectivity_state_notify_on_state_change(grpc_connectivity_state_track void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state) { grpc_connectivity_state_watcher *new = NULL; grpc_connectivity_state_watcher *w; + if (tracker->current_state == state) { + return; + } tracker->current_state = state; while ((w = tracker->watchers)) { tracker->watchers = w->next; diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index 4fda07a63fe..e6e743fa7a4 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -173,7 +173,7 @@ loop: p->checking_subchannel %= p->num_subchannels; p->checking_connectivity = grpc_subchannel_check_connectivity(p->subchannels[p->checking_subchannel]); p->num_subchannels--; - grpc_subchannel_unref(p->subchannels[p->num_subchannels]); + GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); add_interested_parties_locked(p); if (p->num_subchannels == 0) { abort(); @@ -199,13 +199,13 @@ static void pf_broadcast(grpc_lb_policy *pol, grpc_transport_op *op) { subchannels = gpr_malloc(n * sizeof(*subchannels)); for (i = 0; i < n; i++) { subchannels[i] = p->subchannels[i]; - grpc_subchannel_ref(subchannels[i]); + GRPC_SUBCHANNEL_REF(subchannels[i], "broadcast"); } gpr_mu_unlock(&p->mu); for (i = 0; i < n; i++) { grpc_subchannel_process_transport_op(subchannels[i], op); - grpc_subchannel_unref(subchannels[i]); + GRPC_SUBCHANNEL_UNREF(subchannels[i], "broadcast"); } gpr_free(subchannels); } diff --git a/src/core/client_config/lb_policy.c b/src/core/client_config/lb_policy.c index 5a2b70b94e0..2daba14c2ae 100644 --- a/src/core/client_config/lb_policy.c +++ b/src/core/client_config/lb_policy.c @@ -49,3 +49,7 @@ void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset, grpc_iomgr_closure *on_complete) { policy->vtable->pick(policy, pollset, initial_metadata, target, on_complete); } + +void grpc_lb_policy_broadcast(grpc_lb_policy *policy, grpc_transport_op *op) { + policy->vtable->broadcast(policy, op); +} diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 42be9152cba..dcefa6e27ed 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -85,4 +85,6 @@ void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset, grpc_subchannel **target, grpc_iomgr_closure *on_complete); +void grpc_lb_policy_broadcast(grpc_lb_policy *policy, grpc_transport_op *op); + #endif /* GRPC_INTERNAL_CORE_CONFIG_LB_POLICY_H */ diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 5cbb5d99716..e441befc0c9 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -105,14 +105,68 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); static gpr_timespec compute_connect_deadline(grpc_subchannel *c); static void subchannel_connected(void *subchannel, int iomgr_success); +/* + * connection implementation + */ + +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +#define CONNECTION_REF(c, r) connection_ref((c), __FILE__, __LINE__, (r)) +#define CONNECTION_UNREF(c, r) connection_unref((c), __FILE__, __LINE__, (r)) +#else +#define CONNECTION_REF(c, r) connection_ref((c)) +#define CONNECTION_UNREF(c, r) connection_unref((c)) +#endif + +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +static void connection_ref(connection *c, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCONN:%p ref %d -> %d %s", + c, (int)c->refs.count, (int)c->refs.count + 1, + reason); +#else +static void connection_ref(connection *c) { +#endif + gpr_ref(&c->refs); +} + +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +static void connection_unref(connection *c, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCONN:%p unref %d -> %d %s", + c, (int)c->refs.count, (int)c->refs.count - 1, + reason); +#else +static void connection_unref(connection *c) { +#endif + if (gpr_unref(&c->refs)) { + GRPC_SUBCHANNEL_UNREF(c->subchannel, "connection"); + gpr_free(c); + } +} + /* * grpc_subchannel implementation */ -void grpc_subchannel_ref(grpc_subchannel *c) { gpr_ref(&c->refs); } +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +void grpc_subchannel_ref(grpc_subchannel *c, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCHAN:%p ref %d -> %d %s", + c, (int)c->refs.count, (int)c->refs.count + 1, + reason); +#else +void grpc_subchannel_ref(grpc_subchannel *c) { +#endif + gpr_ref(&c->refs); +} +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +void grpc_subchannel_unref(grpc_subchannel *c, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCHAN:%p unref %d -> %d %s", + c, (int)c->refs.count, (int)c->refs.count - 1, + reason); +#else void grpc_subchannel_unref(grpc_subchannel *c) { +#endif if (gpr_unref(&c->refs)) { + if (c->active != NULL) CONNECTION_UNREF(c->active, "subchannel"); gpr_free(c->filters); grpc_channel_args_destroy(c->args); gpr_free(c->addr); @@ -178,7 +232,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, gpr_mu_lock(&c->mu); if (c->active != NULL) { con = c->active; - gpr_ref(&con->refs); + CONNECTION_REF(con, "call"); gpr_mu_unlock(&c->mu); *target = create_call(con, initial_op); @@ -194,7 +248,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, if (!c->connecting) { c->connecting = 1; connectivity_state_changed_locked(c); - grpc_subchannel_ref(c); + GRPC_SUBCHANNEL_REF(c, "connection"); gpr_mu_unlock(&c->mu); start_connect(c); @@ -220,7 +274,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, if (grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state, notify)) { do_connect = 1; c->connecting = 1; - grpc_subchannel_ref(c); + GRPC_SUBCHANNEL_REF(c, "connection"); grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); } gpr_mu_unlock(&c->mu); @@ -275,7 +329,7 @@ static void subchannel_connected(void *arg, int iomgr_success) { if (c->connecting_result.transport) { publish_transport(c); } else { - grpc_subchannel_unref(c); + GRPC_SUBCHANNEL_UNREF(c, "connection"); /* TODO(ctiller): retry after sleeping */ abort(); } @@ -304,17 +358,29 @@ static void connectivity_state_changed_locked(grpc_subchannel *c) { * grpc_subchannel_call implementation */ -void grpc_subchannel_call_ref(grpc_subchannel_call *call) { - gpr_ref(&call->refs); +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +void grpc_subchannel_call_ref(grpc_subchannel_call *c, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCALL:%p ref %d -> %d %s", + c, (int)c->refs.count, (int)c->refs.count + 1, + reason); +#else +void grpc_subchannel_call_ref(grpc_subchannel_call *c) { +#endif + gpr_ref(&c->refs); } -void grpc_subchannel_call_unref(grpc_subchannel_call *call) { - if (gpr_unref(&call->refs)) { - grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(call)); - if (gpr_unref(&call->connection->refs)) { - gpr_free(call->connection); - } - gpr_free(call); +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +void grpc_subchannel_call_unref(grpc_subchannel_call *c, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCALL:%p unref %d -> %d %s", + c, (int)c->refs.count, (int)c->refs.count - 1, + reason); +#else +void grpc_subchannel_call_unref(grpc_subchannel_call *c) { +#endif + if (gpr_unref(&c->refs)) { + grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(c)); + CONNECTION_UNREF(c->connection, "call"); + gpr_free(c); } } diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 60b95d3d8fc..7cdcccce8fa 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -37,14 +37,33 @@ #include "src/core/channel/channel_stack.h" #include "src/core/client_config/connector.h" +#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG + /** A (sub-)channel that knows how to connect to exactly one target address. Provides a target for load balancing. */ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +#define GRPC_SUBCHANNEL_REF(c, r) grpc_subchannel_ref((c), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_UNREF(c, r) grpc_subchannel_unref((c), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_CALL_REF(c, r) grpc_subchannel_call_ref((c), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_CALL_UNREF(c, r) grpc_subchannel_call_unref((c), __FILE__, __LINE__, (r)) +void grpc_subchannel_ref(grpc_subchannel *channel, const char *file, int line, const char *reason); +void grpc_subchannel_unref(grpc_subchannel *channel, const char *file, int line, const char *reason); +void grpc_subchannel_call_ref(grpc_subchannel_call *call, const char *file, int line, const char *reason); +void grpc_subchannel_call_unref(grpc_subchannel_call *call, const char *file, int line, const char *reason); +#else +#define GRPC_SUBCHANNEL_REF(c, r) grpc_subchannel_ref((c)) +#define GRPC_SUBCHANNEL_UNREF(c, r) grpc_subchannel_unref((c)) +#define GRPC_SUBCHANNEL_CALL_REF(c, r) grpc_subchannel_call_ref((c)) +#define GRPC_SUBCHANNEL_CALL_UNREF(c, r) grpc_subchannel_call_unref((c)) void grpc_subchannel_ref(grpc_subchannel *channel); void grpc_subchannel_unref(grpc_subchannel *channel); +void grpc_subchannel_call_ref(grpc_subchannel_call *call); +void grpc_subchannel_call_unref(grpc_subchannel_call *call); +#endif /** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, @@ -55,9 +74,6 @@ void grpc_subchannel_create_call(grpc_subchannel *subchannel, /** process a transport level op */ void grpc_subchannel_process_transport_op(grpc_subchannel *subchannel, grpc_transport_op *op); -void grpc_subchannel_call_ref(grpc_subchannel_call *call); -void grpc_subchannel_call_unref(grpc_subchannel_call *call); - /** poll the current connectivity state of a channel */ grpc_connectivity_state grpc_subchannel_check_connectivity( grpc_subchannel *channel); diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 8c136af8412..4857912b4f6 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -93,9 +93,8 @@ grpc_channel *grpc_channel_create_from_filters( grpc_channel *channel = gpr_malloc(size); GPR_ASSERT(grpc_is_initialized() && "call grpc_init()"); channel->is_client = is_client; - /* decremented by grpc_channel_destroy, and grpc_client_channel_closed if - * is_client */ - gpr_ref_init(&channel->refs, 1 + is_client); + /* decremented by grpc_channel_destroy */ + gpr_ref_init(&channel->refs, 1); channel->metadata_context = mdctx; channel->grpc_status_string = grpc_mdstr_from_string(mdctx, "grpc-status"); channel->grpc_compression_level_string = @@ -237,33 +236,10 @@ void grpc_channel_internal_unref(grpc_channel *channel) { } } -static void default_consumed(void *arg, int iomgr_success) { - grpc_channel *channel = arg; - GRPC_CHANNEL_INTERNAL_UNREF(channel, "op"); -} - -static void execute_op(grpc_channel *channel, grpc_transport_op *op) { - grpc_channel_element *elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0); - if (op->on_consumed == NULL) { - GRPC_CHANNEL_INTERNAL_REF(channel, "op"); - op->on_consumed = gpr_malloc(sizeof(*op->on_consumed)); - grpc_iomgr_closure_init(op->on_consumed, default_consumed, channel); - } - elem->filter->start_transport_op(elem, op); -} - void grpc_channel_destroy(grpc_channel *channel) { - grpc_transport_op op; - memset(&op, 0, sizeof(op)); - op.disconnect = 1; - execute_op(channel, &op); GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel"); } -void grpc_client_channel_closed(grpc_channel_element *elem) { - GRPC_CHANNEL_INTERNAL_UNREF(CHANNEL_FROM_TOP_ELEM(elem), "closed"); -} - grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel) { return CHANNEL_STACK_FROM_CHANNEL(channel); } diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h index 516c0ac5596..71f8a557312 100644 --- a/src/core/surface/channel.h +++ b/src/core/surface/channel.h @@ -58,8 +58,6 @@ grpc_mdstr *grpc_channel_get_compresssion_level_string(grpc_channel *channel); grpc_mdstr *grpc_channel_get_message_string(grpc_channel *channel); gpr_uint32 grpc_channel_get_max_message_length(grpc_channel *channel); -void grpc_client_channel_closed(grpc_channel_element *elem); - #ifdef GRPC_CHANNEL_REF_COUNT_DEBUG void grpc_channel_internal_ref(grpc_channel *channel, const char *reason); void grpc_channel_internal_unref(grpc_channel *channel, const char *reason); From d7b68e72f55e34cafd0042623b707814a6c2b64e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sun, 28 Jun 2015 11:41:09 -0700 Subject: [PATCH 050/124] Simple request unsecure passes with new client_config code --- src/core/channel/client_channel.c | 22 +-- src/core/client_config/client_config.c | 6 +- .../client_config/lb_policies/pick_first.c | 36 ++-- src/core/client_config/lb_policy.c | 27 ++- src/core/client_config/lb_policy.h | 18 +- .../client_config/resolvers/dns_resolver.c | 11 +- src/core/client_config/subchannel.c | 161 +++++++++--------- src/core/client_config/subchannel.h | 17 -- src/core/surface/channel_create.c | 1 + 9 files changed, 164 insertions(+), 135 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 19700a90a6e..b33ef7842fb 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -297,14 +297,14 @@ static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_ gpr_mu_lock(&chand->mu_config); lb_policy = chand->lb_policy; if (lb_policy) { - grpc_lb_policy_ref(lb_policy); + GRPC_LB_POLICY_REF(lb_policy, "pick"); gpr_mu_unlock(&chand->mu_config); calld->state = CALL_WAITING_FOR_PICK; gpr_mu_unlock(&calld->mu_state); pick_target(lb_policy, calld); - grpc_lb_policy_unref(lb_policy); + GRPC_LB_POLICY_UNREF(lb_policy, "pick"); } else { calld->state = CALL_WAITING_FOR_CONFIG; add_to_lb_policy_wait_queue_locked_state_config(elem); @@ -332,9 +332,9 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { grpc_resolver *old_resolver; grpc_iomgr_closure *wakeup_closures = NULL; - if (chand->incoming_configuration) { + if (chand->incoming_configuration != NULL) { lb_policy = grpc_client_config_get_lb_policy(chand->incoming_configuration); - grpc_lb_policy_ref(lb_policy); + GRPC_LB_POLICY_REF(lb_policy, "channel"); grpc_client_config_unref(chand->incoming_configuration); } @@ -357,7 +357,7 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { } if (old_lb_policy) { - grpc_lb_policy_unref(old_lb_policy); + GRPC_LB_POLICY_UNREF(old_lb_policy, "channel"); } if (iomgr_success) { @@ -391,14 +391,14 @@ static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op if (!is_empty(op, sizeof(*op))) { lb_policy = chand->lb_policy; if (lb_policy) { - grpc_lb_policy_ref(lb_policy); + GRPC_LB_POLICY_REF(lb_policy, "broadcast"); } } gpr_mu_unlock(&chand->mu_config); if (lb_policy) { grpc_lb_policy_broadcast(lb_policy, op); - grpc_lb_policy_unref(lb_policy); + GRPC_LB_POLICY_UNREF(lb_policy, "broadcast"); } if (on_consumed) { @@ -436,7 +436,7 @@ static void destroy_call_elem(grpc_call_element *elem) { case CALL_ACTIVE: subchannel_call = calld->subchannel_call; gpr_mu_unlock(&calld->mu_state); - GRPC_SUBCHANNEL_CALL_UNREF(subchannel_call, "channel"); + grpc_subchannel_call_unref(subchannel_call); break; case CALL_CREATED: case CALL_CANCELLED: @@ -472,11 +472,11 @@ static void init_channel_elem(grpc_channel_element *elem, static void destroy_channel_elem(grpc_channel_element *elem) { channel_data *chand = elem->channel_data; - if (chand->resolver) { + if (chand->resolver != NULL) { grpc_resolver_unref(chand->resolver); } - if (chand->lb_policy) { - grpc_lb_policy_unref(chand->lb_policy); + if (chand->lb_policy != NULL) { + GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel"); } gpr_mu_destroy(&chand->mu_config); } diff --git a/src/core/client_config/client_config.c b/src/core/client_config/client_config.c index bc8dcec54ed..44538241485 100644 --- a/src/core/client_config/client_config.c +++ b/src/core/client_config/client_config.c @@ -53,7 +53,7 @@ void grpc_client_config_ref(grpc_client_config *c) { gpr_ref(&c->refs); } void grpc_client_config_unref(grpc_client_config *c) { if (gpr_unref(&c->refs)) { - grpc_lb_policy_unref(c->lb_policy); + GRPC_LB_POLICY_UNREF(c->lb_policy, "client_config"); gpr_free(c); } } @@ -61,10 +61,10 @@ void grpc_client_config_unref(grpc_client_config *c) { void grpc_client_config_set_lb_policy(grpc_client_config *c, grpc_lb_policy *lb_policy) { if (lb_policy) { - grpc_lb_policy_ref(lb_policy); + GRPC_LB_POLICY_REF(lb_policy, "client_config"); } if (c->lb_policy) { - grpc_lb_policy_unref(c->lb_policy); + GRPC_LB_POLICY_UNREF(c->lb_policy, "client_config"); } c->lb_policy = lb_policy; } diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index e6e743fa7a4..9d6c264e37c 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -48,8 +48,6 @@ typedef struct pending_pick { typedef struct { /** base policy: must be first */ grpc_lb_policy base; - /** ref count */ - gpr_refcount refs; /** all our subchannels */ grpc_subchannel **subchannels; size_t num_subchannels; @@ -75,18 +73,15 @@ typedef struct { grpc_connectivity_state_tracker state_tracker; } pick_first_lb_policy; -void pf_ref(grpc_lb_policy *pol) { - pick_first_lb_policy *p = (pick_first_lb_policy *)pol; - gpr_ref(&p->refs); -} - -void pf_unref(grpc_lb_policy *pol) { - pick_first_lb_policy *p = (pick_first_lb_policy *)pol; - if (gpr_unref(&p->refs)) { - gpr_free(p->subchannels); - gpr_mu_destroy(&p->mu); - gpr_free(p); +void pf_destroy(grpc_lb_policy *pol) { + pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + size_t i; + for (i = 0; i < p->num_subchannels; i++) { + grpc_subchannel_unref(p->subchannels[i]); } + gpr_free(p->subchannels); + gpr_mu_destroy(&p->mu); + gpr_free(p); } void pf_shutdown(grpc_lb_policy *pol) { @@ -109,7 +104,7 @@ void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, p->started_picking = 1; p->checking_subchannel = 0; p->checking_connectivity = GRPC_CHANNEL_IDLE; - pf_ref(pol); + GRPC_LB_POLICY_REF(pol, "pick_first_connectivity"); grpc_subchannel_notify_on_state_change(p->subchannels[p->checking_subchannel], &p->checking_connectivity, &p->connectivity_changed); } grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], pollset); @@ -173,7 +168,7 @@ loop: p->checking_subchannel %= p->num_subchannels; p->checking_connectivity = grpc_subchannel_check_connectivity(p->subchannels[p->checking_subchannel]); p->num_subchannels--; - GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); + grpc_subchannel_unref(p->subchannels[p->num_subchannels]); add_interested_parties_locked(p); if (p->num_subchannels == 0) { abort(); @@ -184,7 +179,7 @@ loop: gpr_mu_unlock(&p->mu); if (unref) { - pf_unref(&p->base); + GRPC_LB_POLICY_UNREF(&p->base, "pick_first_connectivity"); } } @@ -199,13 +194,13 @@ static void pf_broadcast(grpc_lb_policy *pol, grpc_transport_op *op) { subchannels = gpr_malloc(n * sizeof(*subchannels)); for (i = 0; i < n; i++) { subchannels[i] = p->subchannels[i]; - GRPC_SUBCHANNEL_REF(subchannels[i], "broadcast"); + grpc_subchannel_ref(subchannels[i]); } gpr_mu_unlock(&p->mu); for (i = 0; i < n; i++) { grpc_subchannel_process_transport_op(subchannels[i], op); - GRPC_SUBCHANNEL_UNREF(subchannels[i], "broadcast"); + grpc_subchannel_unref(subchannels[i]); } gpr_free(subchannels); } @@ -227,15 +222,14 @@ static void pf_notify_on_state_change(grpc_lb_policy *pol, grpc_connectivity_sta } static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = { - pf_ref, pf_unref, pf_shutdown, pf_pick, pf_broadcast, pf_check_connectivity, pf_notify_on_state_change}; + pf_destroy, pf_shutdown, pf_pick, pf_broadcast, pf_check_connectivity, pf_notify_on_state_change}; grpc_lb_policy *grpc_create_pick_first_lb_policy(grpc_subchannel **subchannels, size_t num_subchannels) { pick_first_lb_policy *p = gpr_malloc(sizeof(*p)); GPR_ASSERT(num_subchannels); memset(p, 0, sizeof(*p)); - p->base.vtable = &pick_first_lb_policy_vtable; - gpr_ref_init(&p->refs, 1); + grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable); p->subchannels = gpr_malloc(sizeof(grpc_subchannel *) * num_subchannels); p->num_subchannels = num_subchannels; memcpy(p->subchannels, subchannels, diff --git a/src/core/client_config/lb_policy.c b/src/core/client_config/lb_policy.c index 2daba14c2ae..dfe21cf443a 100644 --- a/src/core/client_config/lb_policy.c +++ b/src/core/client_config/lb_policy.c @@ -33,10 +33,33 @@ #include "src/core/client_config/lb_policy.h" -void grpc_lb_policy_ref(grpc_lb_policy *policy) { policy->vtable->ref(policy); } +void grpc_lb_policy_init(grpc_lb_policy *policy, const grpc_lb_policy_vtable *vtable) { + policy->vtable = vtable; + gpr_ref_init(&policy->refs, 1); +} + +#ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG +void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "LB_POLICY:%p ref %d -> %d %s", + policy, (int)policy->refs.count, (int)policy->refs.count + 1, + reason); +#else +void grpc_lb_policy_ref(grpc_lb_policy *policy) { +#endif + gpr_ref(&policy->refs); +} +#ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG +void grpc_lb_policy_unref(grpc_lb_policy *policy, const char *file, int line, const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "LB_POLICY:%p unref %d -> %d %s", + policy, (int)policy->refs.count, (int)policy->refs.count - 1, + reason); +#else void grpc_lb_policy_unref(grpc_lb_policy *policy) { - policy->vtable->unref(policy); +#endif + if (gpr_unref(&policy->refs)) { + policy->vtable->destroy(policy); + } } void grpc_lb_policy_shutdown(grpc_lb_policy *policy) { diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index dcefa6e27ed..890a89f5c97 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -46,11 +46,11 @@ typedef void (*grpc_lb_completion)(void *cb_arg, grpc_subchannel *subchannel, struct grpc_lb_policy { const grpc_lb_policy_vtable *vtable; + gpr_refcount refs; }; struct grpc_lb_policy_vtable { - void (*ref)(grpc_lb_policy *policy); - void (*unref)(grpc_lb_policy *policy); + void (*destroy)(grpc_lb_policy *policy); void (*shutdown)(grpc_lb_policy *policy); @@ -70,8 +70,22 @@ struct grpc_lb_policy_vtable { void (*notify_on_state_change)(grpc_lb_policy *policy, grpc_connectivity_state *state, grpc_iomgr_closure *closure); }; +#define GRPC_LB_POLICY_REFCOUNT_DEBUG + +#ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG +#define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p), __FILE__, __LINE__, (r)) +void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line, const char *reason); +void grpc_lb_policy_unref(grpc_lb_policy *policy, const char *file, int line, const char *reason); +#else +#define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p)) +#define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p)) void grpc_lb_policy_ref(grpc_lb_policy *policy); void grpc_lb_policy_unref(grpc_lb_policy *policy); +#endif + +/** called by concrete implementations to initialize the base struct */ +void grpc_lb_policy_init(grpc_lb_policy *policy, const grpc_lb_policy_vtable *vtable); /** Start shutting down (fail any pending picks) */ void grpc_lb_policy_shutdown(grpc_lb_policy *policy); diff --git a/src/core/client_config/resolvers/dns_resolver.c b/src/core/client_config/resolvers/dns_resolver.c index ba826752750..8693bcf5eb4 100644 --- a/src/core/client_config/resolvers/dns_resolver.c +++ b/src/core/client_config/resolvers/dns_resolver.c @@ -145,6 +145,7 @@ static void dns_on_resolved(void *arg, grpc_resolved_addresses *addresses) { grpc_client_config *config = NULL; grpc_subchannel **subchannels; grpc_subchannel_args args; + grpc_lb_policy *lb_policy; size_t i; if (addresses) { config = grpc_client_config_create(); @@ -156,8 +157,9 @@ static void dns_on_resolved(void *arg, grpc_resolved_addresses *addresses) { subchannels[i] = grpc_subchannel_factory_create_subchannel( r->subchannel_factory, &args); } - grpc_client_config_set_lb_policy( - config, r->lb_policy_factory(subchannels, addresses->naddrs)); + lb_policy = r->lb_policy_factory(subchannels, addresses->naddrs); + grpc_client_config_set_lb_policy(config, lb_policy); + GRPC_LB_POLICY_UNREF(lb_policy, "construction"); } gpr_mu_lock(&r->mu); if (r->resolved_config) { @@ -167,6 +169,8 @@ static void dns_on_resolved(void *arg, grpc_resolved_addresses *addresses) { r->resolved_version++; dns_maybe_finish_next_locked(r); gpr_mu_unlock(&r->mu); + + dns_unref(&r->base); } static void dns_start_resolving_locked(dns_resolver *r) { @@ -188,6 +192,9 @@ static void dns_maybe_finish_next_locked(dns_resolver *r) { static void dns_destroy(dns_resolver *r) { gpr_mu_destroy(&r->mu); + if (r->resolved_config) { + grpc_client_config_unref(r->resolved_config); + } grpc_subchannel_factory_unref(r->subchannel_factory); gpr_free(r->name); gpr_free(r->default_port); diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index e441befc0c9..b4da9cda3f3 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -42,7 +42,10 @@ #include "src/core/channel/connectivity_state.h" typedef struct { - gpr_refcount refs; + /* all fields protected by subchannel->mu */ + /** refcount */ + int refs; + /** parent subchannel */ grpc_subchannel *subchannel; } connection; @@ -54,7 +57,6 @@ typedef struct waiting_for_connect { } waiting_for_connect; struct grpc_subchannel { - gpr_refcount refs; grpc_connector *connector; /** non-transport related channel filters */ @@ -83,6 +85,8 @@ struct grpc_subchannel { /** active connection */ connection *active; + /** refcount */ + int refs; /** are we connecting */ int connecting; /** things waiting for a connection */ @@ -105,76 +109,76 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); static gpr_timespec compute_connect_deadline(grpc_subchannel *c); static void subchannel_connected(void *subchannel, int iomgr_success); +static void subchannel_ref_locked(grpc_subchannel *c); +static int subchannel_unref_locked(grpc_subchannel *c) GRPC_MUST_USE_RESULT; +static void connection_ref_locked(connection *c); +static grpc_subchannel *connection_unref_locked(connection *c) GRPC_MUST_USE_RESULT; +static void subchannel_destroy(grpc_subchannel *c); + /* * connection implementation */ -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -#define CONNECTION_REF(c, r) connection_ref((c), __FILE__, __LINE__, (r)) -#define CONNECTION_UNREF(c, r) connection_unref((c), __FILE__, __LINE__, (r)) -#else -#define CONNECTION_REF(c, r) connection_ref((c)) -#define CONNECTION_UNREF(c, r) connection_unref((c)) -#endif - -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -static void connection_ref(connection *c, const char *file, int line, const char *reason) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCONN:%p ref %d -> %d %s", - c, (int)c->refs.count, (int)c->refs.count + 1, - reason); -#else -static void connection_ref(connection *c) { -#endif - gpr_ref(&c->refs); +static void connection_destroy(connection *c) { + GPR_ASSERT(c->refs == 0); + grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CONNECTION(c)); + gpr_free(c); } -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -static void connection_unref(connection *c, const char *file, int line, const char *reason) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCONN:%p unref %d -> %d %s", - c, (int)c->refs.count, (int)c->refs.count - 1, - reason); -#else -static void connection_unref(connection *c) { -#endif - if (gpr_unref(&c->refs)) { - GRPC_SUBCHANNEL_UNREF(c->subchannel, "connection"); - gpr_free(c); +static void connection_ref_locked(connection *c) { + subchannel_ref_locked(c->subchannel); + ++c->refs; +} + +static grpc_subchannel *connection_unref_locked(connection *c) { + grpc_subchannel *destroy = NULL; + if (subchannel_unref_locked(c->subchannel)) { + destroy = c->subchannel; + } + if (--c->refs == 0 && c->subchannel->active != c) { + connection_destroy(c); } + return destroy; } + /* * grpc_subchannel implementation */ -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -void grpc_subchannel_ref(grpc_subchannel *c, const char *file, int line, const char *reason) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCHAN:%p ref %d -> %d %s", - c, (int)c->refs.count, (int)c->refs.count + 1, - reason); -#else -void grpc_subchannel_ref(grpc_subchannel *c) { -#endif - gpr_ref(&c->refs); +static void subchannel_ref_locked(grpc_subchannel *c) { + ++c->refs; +} + +static int subchannel_unref_locked(grpc_subchannel *c) { + return --c->refs == 0; +} + +void grpc_subchannel_ref(grpc_subchannel *c) { + gpr_mu_lock(&c->mu); + subchannel_ref_locked(c); + gpr_mu_unlock(&c->mu); } -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -void grpc_subchannel_unref(grpc_subchannel *c, const char *file, int line, const char *reason) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCHAN:%p unref %d -> %d %s", - c, (int)c->refs.count, (int)c->refs.count - 1, - reason); -#else void grpc_subchannel_unref(grpc_subchannel *c) { -#endif - if (gpr_unref(&c->refs)) { - if (c->active != NULL) CONNECTION_UNREF(c->active, "subchannel"); - gpr_free(c->filters); - grpc_channel_args_destroy(c->args); - gpr_free(c->addr); - grpc_mdctx_unref(c->mdctx); - grpc_pollset_set_destroy(&c->pollset_set); - grpc_connectivity_state_destroy(&c->state_tracker); - gpr_free(c); - } + int destroy; + gpr_mu_lock(&c->mu); + destroy = subchannel_unref_locked(c); + gpr_mu_unlock(&c->mu); + if (destroy) subchannel_destroy(c); +} + +static void subchannel_destroy(grpc_subchannel *c) { + if (c->active != NULL) { + connection_destroy(c->active); + } + gpr_free(c->filters); + grpc_channel_args_destroy(c->args); + gpr_free(c->addr); + grpc_mdctx_unref(c->mdctx); + grpc_pollset_set_destroy(&c->pollset_set); + grpc_connectivity_state_destroy(&c->state_tracker); + gpr_free(c); } void grpc_subchannel_add_interested_party(grpc_subchannel *c, @@ -191,7 +195,7 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, grpc_subchannel_args *args) { grpc_subchannel *c = gpr_malloc(sizeof(*c)); memset(c, 0, sizeof(*c)); - gpr_ref_init(&c->refs, 1); + c->refs = 1; c->connector = connector; grpc_connector_ref(c->connector); c->num_filters = args->filter_count; @@ -232,7 +236,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, gpr_mu_lock(&c->mu); if (c->active != NULL) { con = c->active; - CONNECTION_REF(con, "call"); + connection_ref_locked(con); gpr_mu_unlock(&c->mu); *target = create_call(con, initial_op); @@ -248,7 +252,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, if (!c->connecting) { c->connecting = 1; connectivity_state_changed_locked(c); - GRPC_SUBCHANNEL_REF(c, "connection"); + subchannel_ref_locked(c); gpr_mu_unlock(&c->mu); start_connect(c); @@ -274,7 +278,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, if (grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state, notify)) { do_connect = 1; c->connecting = 1; - GRPC_SUBCHANNEL_REF(c, "connection"); + subchannel_ref_locked(c); grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); } gpr_mu_unlock(&c->mu); @@ -294,6 +298,7 @@ static void publish_transport(grpc_subchannel *c) { size_t num_filters; const grpc_channel_filter **filters; waiting_for_connect *w4c; + int destroy; num_filters = c->num_filters + c->connecting_result.num_filters + 1; filters = gpr_malloc(sizeof(*filters) * num_filters); @@ -305,7 +310,7 @@ static void publish_transport(grpc_subchannel *c) { con = gpr_malloc(sizeof(connection) + channel_stack_size); stk = (grpc_channel_stack *)(con + 1); - gpr_ref_init(&con->refs, 1); + con->refs = 0; con->subchannel = c; grpc_channel_stack_init(filters, num_filters, c->args, c->mdctx, stk); grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); @@ -319,9 +324,14 @@ static void publish_transport(grpc_subchannel *c) { while ((w4c = c->waiting)) { abort(); /* not implemented */ } + destroy = subchannel_unref_locked(c); gpr_mu_unlock(&c->mu); gpr_free(filters); + + if (destroy) { + subchannel_destroy(c); + } } static void subchannel_connected(void *arg, int iomgr_success) { @@ -329,7 +339,11 @@ static void subchannel_connected(void *arg, int iomgr_success) { if (c->connecting_result.transport) { publish_transport(c); } else { - GRPC_SUBCHANNEL_UNREF(c, "connection"); + int destroy; + gpr_mu_lock(&c->mu); + destroy = subchannel_unref_locked(c); + gpr_mu_unlock(&c->mu); + if (destroy) subchannel_destroy(c); /* TODO(ctiller): retry after sleeping */ abort(); } @@ -358,29 +372,22 @@ static void connectivity_state_changed_locked(grpc_subchannel *c) { * grpc_subchannel_call implementation */ -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -void grpc_subchannel_call_ref(grpc_subchannel_call *c, const char *file, int line, const char *reason) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCALL:%p ref %d -> %d %s", - c, (int)c->refs.count, (int)c->refs.count + 1, - reason); -#else void grpc_subchannel_call_ref(grpc_subchannel_call *c) { -#endif gpr_ref(&c->refs); } -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -void grpc_subchannel_call_unref(grpc_subchannel_call *c, const char *file, int line, const char *reason) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "SUBCALL:%p unref %d -> %d %s", - c, (int)c->refs.count, (int)c->refs.count - 1, - reason); -#else void grpc_subchannel_call_unref(grpc_subchannel_call *c) { -#endif if (gpr_unref(&c->refs)) { + gpr_mu *mu = &c->connection->subchannel->mu; + grpc_subchannel *destroy; grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(c)); - CONNECTION_UNREF(c->connection, "call"); + gpr_mu_lock(mu); + destroy = connection_unref_locked(c->connection); + gpr_mu_unlock(mu); gpr_free(c); + if (destroy) { + subchannel_destroy(destroy); + } } } diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 7cdcccce8fa..8155aba14cc 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -37,33 +37,16 @@ #include "src/core/channel/channel_stack.h" #include "src/core/client_config/connector.h" -#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG - /** A (sub-)channel that knows how to connect to exactly one target address. Provides a target for load balancing. */ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; -#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -#define GRPC_SUBCHANNEL_REF(c, r) grpc_subchannel_ref((c), __FILE__, __LINE__, (r)) -#define GRPC_SUBCHANNEL_UNREF(c, r) grpc_subchannel_unref((c), __FILE__, __LINE__, (r)) -#define GRPC_SUBCHANNEL_CALL_REF(c, r) grpc_subchannel_call_ref((c), __FILE__, __LINE__, (r)) -#define GRPC_SUBCHANNEL_CALL_UNREF(c, r) grpc_subchannel_call_unref((c), __FILE__, __LINE__, (r)) -void grpc_subchannel_ref(grpc_subchannel *channel, const char *file, int line, const char *reason); -void grpc_subchannel_unref(grpc_subchannel *channel, const char *file, int line, const char *reason); -void grpc_subchannel_call_ref(grpc_subchannel_call *call, const char *file, int line, const char *reason); -void grpc_subchannel_call_unref(grpc_subchannel_call *call, const char *file, int line, const char *reason); -#else -#define GRPC_SUBCHANNEL_REF(c, r) grpc_subchannel_ref((c)) -#define GRPC_SUBCHANNEL_UNREF(c, r) grpc_subchannel_unref((c)) -#define GRPC_SUBCHANNEL_CALL_REF(c, r) grpc_subchannel_call_ref((c)) -#define GRPC_SUBCHANNEL_CALL_UNREF(c, r) grpc_subchannel_call_unref((c)) void grpc_subchannel_ref(grpc_subchannel *channel); void grpc_subchannel_unref(grpc_subchannel *channel); void grpc_subchannel_call_ref(grpc_subchannel_call *call); void grpc_subchannel_call_unref(grpc_subchannel_call *call); -#endif /** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index a00c08a8300..494a44725ad 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -163,6 +163,7 @@ grpc_channel *grpc_channel_create(const char *target, channel = grpc_channel_create_from_filters(filters, n, args, mdctx, 1); grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); + grpc_resolver_unref(resolver); return channel; } From 73f36bdb6cf4218badaf851b0f668d453f33f6f1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sun, 28 Jun 2015 16:04:47 -0700 Subject: [PATCH 051/124] Fix run_tests forever mode --- tools/run_tests/run_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a0e0fac27b1..fd90613ad66 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -496,7 +496,7 @@ class TestCache(object): self.parse(json.loads(f.read())) -def _build_and_run(check_cancelled, newline_on_success, travis, cache, xml_report): +def _build_and_run(check_cancelled, newline_on_success, travis, cache, xml_report=None): """Do one pass of building & running tests.""" # build latest sequentially if not jobset.run(build_steps, maxjobs=1, From acf0f07dfcb8db090528d6dc4dd7a6f7c1132f30 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 08:24:16 -0700 Subject: [PATCH 052/124] Unix resolver, bug fixes --- BUILD | 6 + Makefile | 2 + build.json | 2 + gRPC.podspec | 3 + src/core/client_config/lb_policy.h | 2 - .../resolvers/unix_resolver_posix.c | 209 ++++++++++++++++++ .../resolvers/unix_resolver_posix.h | 44 ++++ src/core/security/client_auth_filter.c | 9 +- src/core/security/server_auth_filter.c | 9 +- src/core/security/server_secure_chttp2.c | 16 +- src/core/surface/init.c | 9 + src/core/surface/secure_channel_create.c | 147 ++++++++++-- test/core/bad_client/bad_client.c | 11 +- test/core/channel/channel_stack_test.c | 3 +- test/core/client_config/uri_parser_test.c | 4 - .../fixtures/chttp2_fullstack_uds_posix.c | 1 - .../fixtures/chttp2_fullstack_with_poll.c | 1 - .../end2end/fixtures/chttp2_socket_pair.c | 26 ++- .../chttp2_socket_pair_one_byte_at_a_time.c | 26 ++- .../chttp2_socket_pair_with_grpc_trace.c | 26 ++- tools/doxygen/Doxyfile.core.internal | 2 + tools/run_tests/sources_and_headers.json | 6 + vsprojects/grpc/grpc.vcxproj | 3 + vsprojects/grpc/grpc.vcxproj.filters | 6 + .../grpc_unsecure/grpc_unsecure.vcxproj | 3 + .../grpc_unsecure.vcxproj.filters | 6 + 26 files changed, 495 insertions(+), 87 deletions(-) create mode 100644 src/core/client_config/resolvers/unix_resolver_posix.c create mode 100644 src/core/client_config/resolvers/unix_resolver_posix.h diff --git a/BUILD b/BUILD index 201d8449c88..a21004c4ed2 100644 --- a/BUILD +++ b/BUILD @@ -165,6 +165,7 @@ cc_library( "src/core/client_config/resolver_factory.h", "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", "src/core/client_config/uri_parser.h", @@ -281,6 +282,7 @@ cc_library( "src/core/client_config/resolver_factory.c", "src/core/client_config/resolver_registry.c", "src/core/client_config/resolvers/dns_resolver.c", + "src/core/client_config/resolvers/unix_resolver_posix.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", "src/core/client_config/uri_parser.c", @@ -415,6 +417,7 @@ cc_library( "src/core/client_config/resolver_factory.h", "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", "src/core/client_config/uri_parser.h", @@ -509,6 +512,7 @@ cc_library( "src/core/client_config/resolver_factory.c", "src/core/client_config/resolver_registry.c", "src/core/client_config/resolvers/dns_resolver.c", + "src/core/client_config/resolvers/unix_resolver_posix.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", "src/core/client_config/uri_parser.c", @@ -948,6 +952,7 @@ objc_library( "src/core/client_config/resolver_factory.c", "src/core/client_config/resolver_registry.c", "src/core/client_config/resolvers/dns_resolver.c", + "src/core/client_config/resolvers/unix_resolver_posix.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", "src/core/client_config/uri_parser.c", @@ -1066,6 +1071,7 @@ objc_library( "src/core/client_config/resolver_factory.h", "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", "src/core/client_config/uri_parser.h", diff --git a/Makefile b/Makefile index ff8a41598f1..3180e992e9d 100644 --- a/Makefile +++ b/Makefile @@ -3030,6 +3030,7 @@ LIBGRPC_SRC = \ src/core/client_config/resolver_factory.c \ src/core/client_config/resolver_registry.c \ src/core/client_config/resolvers/dns_resolver.c \ + src/core/client_config/resolvers/unix_resolver_posix.c \ src/core/client_config/subchannel.c \ src/core/client_config/subchannel_factory.c \ src/core/client_config/uri_parser.c \ @@ -3289,6 +3290,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/client_config/resolver_factory.c \ src/core/client_config/resolver_registry.c \ src/core/client_config/resolvers/dns_resolver.c \ + src/core/client_config/resolvers/unix_resolver_posix.c \ src/core/client_config/subchannel.c \ src/core/client_config/subchannel_factory.c \ src/core/client_config/uri_parser.c \ diff --git a/build.json b/build.json index 7893ea3d0f9..3b511c17a80 100644 --- a/build.json +++ b/build.json @@ -126,6 +126,7 @@ "src/core/client_config/resolver_factory.h", "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", "src/core/client_config/uri_parser.h", @@ -220,6 +221,7 @@ "src/core/client_config/resolver_factory.c", "src/core/client_config/resolver_registry.c", "src/core/client_config/resolvers/dns_resolver.c", + "src/core/client_config/resolvers/unix_resolver_posix.c", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel_factory.c", "src/core/client_config/uri_parser.c", diff --git a/gRPC.podspec b/gRPC.podspec index 4cc71e3cf1b..ed82732bd8b 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -167,6 +167,7 @@ Pod::Spec.new do |s| 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', + 'src/core/client_config/resolvers/unix_resolver_posix.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', @@ -290,6 +291,7 @@ Pod::Spec.new do |s| 'src/core/client_config/resolver_factory.c', 'src/core/client_config/resolver_registry.c', 'src/core/client_config/resolvers/dns_resolver.c', + 'src/core/client_config/resolvers/unix_resolver_posix.c', 'src/core/client_config/subchannel.c', 'src/core/client_config/subchannel_factory.c', 'src/core/client_config/uri_parser.c', @@ -423,6 +425,7 @@ Pod::Spec.new do |s| 'src/core/client_config/resolver_factory.h', 'src/core/client_config/resolver_registry.h', 'src/core/client_config/resolvers/dns_resolver.h', + 'src/core/client_config/resolvers/unix_resolver_posix.h', 'src/core/client_config/subchannel.h', 'src/core/client_config/subchannel_factory.h', 'src/core/client_config/uri_parser.h', diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 890a89f5c97..717f26af652 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -70,8 +70,6 @@ struct grpc_lb_policy_vtable { void (*notify_on_state_change)(grpc_lb_policy *policy, grpc_connectivity_state *state, grpc_iomgr_closure *closure); }; -#define GRPC_LB_POLICY_REFCOUNT_DEBUG - #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG #define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p), __FILE__, __LINE__, (r)) #define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p), __FILE__, __LINE__, (r)) diff --git a/src/core/client_config/resolvers/unix_resolver_posix.c b/src/core/client_config/resolvers/unix_resolver_posix.c new file mode 100644 index 00000000000..3dedf94357c --- /dev/null +++ b/src/core/client_config/resolvers/unix_resolver_posix.c @@ -0,0 +1,209 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#ifdef GPR_POSIX_SOCKET + +#include "src/core/client_config/resolvers/unix_resolver_posix.h" + +#include +#include + +#include +#include + +#include "src/core/client_config/lb_policies/pick_first.h" +#include "src/core/iomgr/resolve_address.h" +#include "src/core/support/string.h" + +typedef struct { + /** base class: must be first */ + grpc_resolver base; + /** refcount */ + gpr_refcount refs; + /** subchannel factory */ + grpc_subchannel_factory *subchannel_factory; + /** load balancing policy factory */ + grpc_lb_policy *(*lb_policy_factory)(grpc_subchannel **subchannels, + size_t num_subchannels); + + /** the address that we've 'resolved' */ + struct sockaddr_un addr; + int addr_len; + + /** mutex guarding the rest of the state */ + gpr_mu mu; + /** have we published? */ + int published; + /** pending next completion, or NULL */ + grpc_iomgr_closure *next_completion; + /** target config address for next completion */ + grpc_client_config **target_config; +} unix_resolver; + +static void unix_destroy(unix_resolver *r); + +static void unix_maybe_finish_next_locked(unix_resolver *r); + +static void unix_ref(grpc_resolver *r); +static void unix_unref(grpc_resolver *r); +static void unix_shutdown(grpc_resolver *r); +static void unix_channel_saw_error(grpc_resolver *r, + struct sockaddr *failing_address, + int failing_address_len); +static void unix_next(grpc_resolver *r, grpc_client_config **target_config, + grpc_iomgr_closure *on_complete); + +static const grpc_resolver_vtable unix_resolver_vtable = { + unix_ref, unix_unref, unix_shutdown, unix_channel_saw_error, unix_next}; + +static void unix_ref(grpc_resolver *resolver) { + unix_resolver *r = (unix_resolver *)resolver; + gpr_ref(&r->refs); +} + +static void unix_unref(grpc_resolver *resolver) { + unix_resolver *r = (unix_resolver *)resolver; + if (gpr_unref(&r->refs)) { + unix_destroy(r); + } +} + +static void unix_shutdown(grpc_resolver *resolver) { + unix_resolver *r = (unix_resolver *)resolver; + gpr_mu_lock(&r->mu); + if (r->next_completion != NULL) { + *r->target_config = NULL; + /* TODO(ctiller): add delayed callback */ + grpc_iomgr_add_callback(r->next_completion); + r->next_completion = NULL; + } + gpr_mu_unlock(&r->mu); +} + +static void unix_channel_saw_error(grpc_resolver *resolver, struct sockaddr *sa, + int len) { +} + +static void unix_next(grpc_resolver *resolver, + grpc_client_config **target_config, + grpc_iomgr_closure *on_complete) { + unix_resolver *r = (unix_resolver *)resolver; + gpr_mu_lock(&r->mu); + GPR_ASSERT(!r->next_completion); + r->next_completion = on_complete; + r->target_config = target_config; + unix_maybe_finish_next_locked(r); + gpr_mu_unlock(&r->mu); +} + +static void unix_maybe_finish_next_locked(unix_resolver *r) { + grpc_client_config *cfg; + grpc_lb_policy *lb_policy; + grpc_subchannel *subchannel; + grpc_subchannel_args args; + + if (r->next_completion != NULL && !r->published) { + cfg = grpc_client_config_create(); + memset(&args, 0, sizeof(args)); + args.addr = (struct sockaddr *) &r->addr; + args.addr_len = r->addr_len; + subchannel = grpc_subchannel_factory_create_subchannel(r->subchannel_factory, &args); + lb_policy = r->lb_policy_factory(&subchannel, 1); + grpc_client_config_set_lb_policy(cfg, lb_policy); + GRPC_LB_POLICY_UNREF(lb_policy, "unix"); + r->published = 1; + *r->target_config = cfg; + grpc_iomgr_add_callback(r->next_completion); + r->next_completion = NULL; + } +} + +static void unix_destroy(unix_resolver *r) { + gpr_mu_destroy(&r->mu); + grpc_subchannel_factory_unref(r->subchannel_factory); + gpr_free(r); +} + +static grpc_resolver *unix_create( + grpc_uri *uri, + grpc_lb_policy *(*lb_policy_factory)(grpc_subchannel **subchannels, + size_t num_subchannels), + grpc_subchannel_factory *subchannel_factory) { + unix_resolver *r; + + if (0 != strcmp(uri->authority, "")) { + gpr_log(GPR_ERROR, "authority based uri's not supported"); + return NULL; + } + + r = gpr_malloc(sizeof(unix_resolver)); + memset(r, 0, sizeof(*r)); + gpr_ref_init(&r->refs, 1); + gpr_mu_init(&r->mu); + r->base.vtable = &unix_resolver_vtable; + r->subchannel_factory = subchannel_factory; + r->lb_policy_factory = lb_policy_factory; + + r->addr.sun_family = AF_UNIX; + strcpy(r->addr.sun_path, uri->path); + r->addr_len = strlen(r->addr.sun_path) + sizeof(r->addr.sun_family) + 1; + + grpc_subchannel_factory_ref(subchannel_factory); + return &r->base; +} + +/* + * FACTORY + */ + +static void unix_factory_ref(grpc_resolver_factory *factory) {} + +static void unix_factory_unref(grpc_resolver_factory *factory) {} + +static grpc_resolver *unix_factory_create_resolver( + grpc_resolver_factory *factory, grpc_uri *uri, + grpc_subchannel_factory *subchannel_factory) { + return unix_create(uri, grpc_create_pick_first_lb_policy, + subchannel_factory); +} + +static const grpc_resolver_factory_vtable unix_factory_vtable = { + unix_factory_ref, unix_factory_unref, unix_factory_create_resolver}; +static grpc_resolver_factory unix_resolver_factory = {&unix_factory_vtable}; + +grpc_resolver_factory *grpc_unix_resolver_factory_create() { + return &unix_resolver_factory; +} + +#endif diff --git a/src/core/client_config/resolvers/unix_resolver_posix.h b/src/core/client_config/resolvers/unix_resolver_posix.h new file mode 100644 index 00000000000..a84906f4d65 --- /dev/null +++ b/src/core/client_config/resolvers/unix_resolver_posix.h @@ -0,0 +1,44 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_UNIX_RESOLVER_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_UNIX_RESOLVER_H + +#include + +#include "src/core/client_config/resolver_factory.h" + +/** Create a dns resolver for \a name */ +grpc_resolver_factory *grpc_unix_resolver_factory_create(void); + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_UNIX_RESOLVER_H */ diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index 9ad4723ac52..2c05f73df57 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -253,13 +253,6 @@ static void auth_start_transport_op(grpc_call_element *elem, grpc_call_next_op(elem, op); } -/* Called on special channel events, such as disconnection or new incoming - calls on the server */ -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - grpc_channel_next_op(elem, op); -} - /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, @@ -334,6 +327,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_client_auth_filter = { - auth_start_transport_op, channel_op, sizeof(call_data), + auth_start_transport_op, grpc_channel_next_op, sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem, "client-auth"}; diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c index 2cb4bf612d6..cf5ce4010e3 100644 --- a/src/core/security/server_auth_filter.c +++ b/src/core/security/server_auth_filter.c @@ -58,13 +58,6 @@ static void auth_start_transport_op(grpc_call_element *elem, grpc_call_next_op(elem, op); } -/* Called on special channel events, such as disconnection or new incoming - calls on the server */ -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - grpc_channel_next_op(elem, op); -} - /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, @@ -122,6 +115,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_server_auth_filter = { - auth_start_transport_op, channel_op, sizeof(call_data), init_call_elem, + auth_start_transport_op, grpc_channel_next_op, sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem, "server-auth"}; diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c index 53afa1caade..d76bd86337d 100644 --- a/src/core/security/server_secure_chttp2.c +++ b/src/core/security/server_secure_chttp2.c @@ -75,33 +75,35 @@ static void state_unref(grpc_server_secure_state *state) { } } -static grpc_transport_setup_result setup_transport(void *statep, +static void setup_transport(void *statep, grpc_transport *transport, grpc_mdctx *mdctx) { static grpc_channel_filter const *extra_filters[] = { &grpc_server_auth_filter, &grpc_http_server_filter}; grpc_server_secure_state *state = statep; - grpc_transport_setup_result result; grpc_arg connector_arg = grpc_security_connector_to_arg(state->sc); grpc_channel_args *args_copy = grpc_channel_args_copy_and_add( grpc_server_get_channel_args(state->server), &connector_arg); - result = grpc_server_setup_transport(state->server, transport, extra_filters, + grpc_server_setup_transport(state->server, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), mdctx, args_copy); grpc_channel_args_destroy(args_copy); - return result; } static void on_secure_transport_setup_done(void *statep, grpc_security_status status, grpc_endpoint *secure_endpoint) { grpc_server_secure_state *state = statep; + grpc_transport *transport; + grpc_mdctx *mdctx; if (status == GRPC_SECURITY_OK) { gpr_mu_lock(&state->mu); if (!state->is_shutdown) { - grpc_create_chttp2_transport( - setup_transport, state, grpc_server_get_channel_args(state->server), - secure_endpoint, NULL, 0, grpc_mdctx_create(), 0); + mdctx = grpc_mdctx_create(); + transport = grpc_create_chttp2_transport( + grpc_server_get_channel_args(state->server), + secure_endpoint, NULL, 0, mdctx, 0); + setup_transport(state, transport, mdctx); } else { /* We need to consume this here, because the server may already have gone * away. */ diff --git a/src/core/surface/init.c b/src/core/surface/init.c index 03add814661..9b9ecae27d2 100644 --- a/src/core/surface/init.c +++ b/src/core/surface/init.c @@ -31,6 +31,8 @@ * */ +#include + #include #include #include "src/core/channel/channel_stack.h" @@ -44,6 +46,10 @@ #include "src/core/surface/surface_trace.h" #include "src/core/transport/chttp2_transport.h" +#ifdef GPR_POSIX_SOCKET +#include "src/core/client_config/resolvers/unix_resolver_posix.h" +#endif + static gpr_once g_basic_init = GPR_ONCE_INIT; static gpr_mu g_init_mu; static int g_initializations; @@ -60,6 +66,9 @@ void grpc_init(void) { if (++g_initializations == 1) { grpc_resolver_registry_init("dns:///"); grpc_register_resolver_type("dns", grpc_dns_resolver_factory_create()); +#ifdef GPR_POSIX_SOCKET + grpc_register_resolver_type("unix", grpc_unix_resolver_factory_create()); +#endif grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer("surface", &grpc_surface_trace); grpc_register_tracer("http", &grpc_http_trace); diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index fae3e4e90a1..ad11c3954be 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -31,36 +31,131 @@ * */ -#include "src/core/iomgr/sockaddr.h" - #include #include #include -#include "src/core/channel/census_filter.h" +#include + #include "src/core/channel/channel_args.h" #include "src/core/channel/client_channel.h" -#include "src/core/channel/client_setup.h" -#include "src/core/channel/connected_channel.h" #include "src/core/channel/http_client_filter.h" -#include "src/core/iomgr/resolve_address.h" +#include "src/core/client_config/resolver_registry.h" #include "src/core/iomgr/tcp_client.h" #include "src/core/security/auth_filters.h" #include "src/core/security/credentials.h" #include "src/core/security/secure_transport_setup.h" -#include "src/core/support/string.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" #include "src/core/transport/chttp2_transport.h" -#include -#include -#include -#include -#include -#include #include "src/core/tsi/transport_security_interface.h" +typedef struct { + grpc_connector base; + gpr_refcount refs; + + grpc_channel_security_connector *security_connector; + + grpc_iomgr_closure *notify; + grpc_connect_in_args args; + grpc_connect_out_args *result; +} connector; + +static void connector_ref(grpc_connector *con) { + connector *c = (connector *)con; + gpr_ref(&c->refs); +} + +static void connector_unref(grpc_connector *con) { + connector *c = (connector *)con; + if (gpr_unref(&c->refs)) { + gpr_free(c); + } +} + +static void on_secure_transport_setup_done(void *arg, + grpc_security_status status, + grpc_endpoint *secure_endpoint) { + connector *c = arg; + grpc_iomgr_closure *notify; + if (status != GRPC_SECURITY_OK) { + gpr_log(GPR_ERROR, "Secure transport setup failed with error %d.", status); + memset(c->result, 0, sizeof(*c->result)); + notify = c->notify; + c->notify = NULL; + grpc_iomgr_add_callback(notify); + } else { + c->result->transport = grpc_create_chttp2_transport( + c->args.channel_args, secure_endpoint, + NULL, 0, c->args.metadata_context, 1); + } +} + +static void connected(void *arg, grpc_endpoint *tcp) { + connector *c = arg; + grpc_iomgr_closure *notify; + if (tcp != NULL) { + grpc_setup_secure_transport(&c->security_connector->base, tcp, + on_secure_transport_setup_done, c); + } else { + memset(c->result, 0, sizeof(*c->result)); + notify = c->notify; + c->notify = NULL; + grpc_iomgr_add_callback(notify); + } +} + +static void connector_connect( + grpc_connector *con, const grpc_connect_in_args *args, + grpc_connect_out_args *result, grpc_iomgr_closure *notify) { + connector *c = (connector *)con; + GPR_ASSERT(c->notify == NULL); + GPR_ASSERT(notify->cb); + c->notify = notify; + c->args = *args; + c->result = result; + grpc_tcp_client_connect(connected, c, args->interested_parties, args->addr, args->addr_len, args->deadline); +} + +static const grpc_connector_vtable connector_vtable = {connector_ref, connector_unref, connector_connect}; + +typedef struct { + grpc_subchannel_factory base; + gpr_refcount refs; + grpc_mdctx *mdctx; + grpc_channel_security_connector *security_connector; +} subchannel_factory; + +static void subchannel_factory_ref(grpc_subchannel_factory *scf) { + subchannel_factory *f = (subchannel_factory *)scf; + gpr_ref(&f->refs); +} + +static void subchannel_factory_unref(grpc_subchannel_factory *scf) { + subchannel_factory *f = (subchannel_factory *)scf; + if (gpr_unref(&f->refs)) { + grpc_mdctx_unref(f->mdctx); + gpr_free(f); + } +} + +static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { + subchannel_factory *f = (subchannel_factory *)scf; + connector *c = gpr_malloc(sizeof(*c)); + grpc_subchannel *s; + memset(c, 0, sizeof(*c)); + c->base.vtable = &connector_vtable; + c->security_connector = f->security_connector; + gpr_ref_init(&c->refs, 1); + args->mdctx = f->mdctx; + s = grpc_subchannel_create(&c->base, args); + grpc_connector_unref(&c->base); + return s; +} + +static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchannel_factory_ref, subchannel_factory_unref, subchannel_factory_create_subchannel}; + +#if 0 typedef struct setup setup; /* A single setup request (started via initiate) */ @@ -203,6 +298,8 @@ static grpc_transport_setup_result complete_setup(void *channel_stack, mdctx); } +#endif + /* Create a secure client channel: Asynchronously: - resolve target - connect to it (trying alternatives as presented) @@ -210,13 +307,14 @@ static grpc_transport_setup_result complete_setup(void *channel_stack, grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, const char *target, const grpc_channel_args *args) { - setup *s; grpc_channel *channel; grpc_arg connector_arg; grpc_channel_args *args_copy; grpc_channel_args *new_args_from_connector; grpc_channel_security_connector *connector; grpc_mdctx *mdctx; + grpc_resolver *resolver; + subchannel_factory *f; #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; int n = 0; @@ -233,24 +331,37 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, } mdctx = grpc_mdctx_create(); - s = gpr_malloc(sizeof(setup)); connector_arg = grpc_security_connector_to_arg(&connector->base); args_copy = grpc_channel_args_copy_and_add( new_args_from_connector != NULL ? new_args_from_connector : args, &connector_arg); - filters[n++] = &grpc_client_surface_filter; /* TODO(census) if (grpc_channel_args_is_census_enabled(args)) { filters[n++] = &grpc_client_census_filter; } */ filters[n++] = &grpc_client_channel_filter; GPR_ASSERT(n <= MAX_FILTERS); + + f = gpr_malloc(sizeof(*f)); + f->base.vtable = &subchannel_factory_vtable; + gpr_ref_init(&f->refs, 1); + f->mdctx = mdctx; + f->security_connector = connector; + resolver = grpc_resolver_create(target, &f->base); + if (!resolver) { + return NULL; + } + channel = grpc_channel_create_from_filters(filters, n, args_copy, mdctx, 1); + grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); + grpc_resolver_unref(resolver); + grpc_channel_args_destroy(args_copy); if (new_args_from_connector != NULL) { grpc_channel_args_destroy(new_args_from_connector); } +#if 0 s->target = gpr_strdup(target); s->setup_callback = complete_setup; s->setup_user_data = grpc_channel_get_channel_stack(channel); @@ -258,5 +369,7 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, grpc_client_setup_create_and_attach(grpc_channel_get_channel_stack(channel), args, mdctx, initiate_setup, done_setup, s); +#endif + return channel; } diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index e9adcf34c79..4b889995a18 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -63,12 +63,12 @@ static void done_write(void *arg, grpc_endpoint_cb_status status) { gpr_event_set(&a->done_write, (void *)1); } -static grpc_transport_setup_result server_setup_transport( +static void server_setup_transport( void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { thd_args *a = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; - return grpc_server_setup_transport(a->server, transport, extra_filters, + grpc_server_setup_transport(a->server, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), mdctx, grpc_server_get_channel_args(a->server)); } @@ -80,6 +80,8 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, thd_args a; gpr_thd_id id; char *hex; + grpc_transport *transport; + grpc_mdctx *mdctx = grpc_mdctx_create(); gpr_slice slice = gpr_slice_from_copied_buffer(client_payload, client_payload_length); @@ -103,8 +105,9 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, a.validator = validator; grpc_server_register_completion_queue(a.server, a.cq); grpc_server_start(a.server); - grpc_create_chttp2_transport(server_setup_transport, &a, NULL, sfd.server, - NULL, 0, grpc_mdctx_create(), 0); + transport = grpc_create_chttp2_transport(NULL, sfd.server, + NULL, 0, mdctx, 0); + server_setup_transport(&a, transport, mdctx); /* Bind everything into the same pollset */ grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq)); diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index 78779484b2d..ba778c37758 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -69,8 +69,7 @@ static void call_func(grpc_call_element *elem, grpc_transport_stream_op *op) { ++*(int *)(elem->call_data); } -static void channel_func(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { +static void channel_func(grpc_channel_element *elem, grpc_transport_op *op) { ++*(int *)(elem->channel_data); } diff --git a/test/core/client_config/uri_parser_test.c b/test/core/client_config/uri_parser_test.c index 1dfbcfba6b9..26566d09244 100644 --- a/test/core/client_config/uri_parser_test.c +++ b/test/core/client_config/uri_parser_test.c @@ -60,9 +60,5 @@ int main(int argc, char **argv) { test_succeeds("http://www.google.com:90", "http", "www.google.com:90", ""); test_fails("xyz"); test_fails("http://www.google.com?why-are-you-using-queries"); - - GPR_ASSERT(grpc_has_scheme("http:adfhadf")); - GPR_ASSERT(grpc_has_scheme("http://adfhadf")); - GPR_ASSERT(!grpc_has_scheme("adfhadf")); return 0; } diff --git a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c index 94b54253e4b..351e1c5459b 100644 --- a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c +++ b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c @@ -42,7 +42,6 @@ #include "src/core/channel/http_server_filter.h" #include "src/core/support/string.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" #include "src/core/surface/server.h" #include "src/core/transport/chttp2_transport.h" #include diff --git a/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c b/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c index 00322d4011e..69860d04d5e 100644 --- a/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c +++ b/test/core/end2end/fixtures/chttp2_fullstack_with_poll.c @@ -39,7 +39,6 @@ #include "src/core/channel/connected_channel.h" #include "src/core/channel/http_server_filter.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" #include "src/core/surface/server.h" #include "src/core/transport/chttp2_transport.h" #include diff --git a/test/core/end2end/fixtures/chttp2_socket_pair.c b/test/core/end2end/fixtures/chttp2_socket_pair.c index d84405224b3..9f3b36d5e9e 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair.c @@ -42,7 +42,6 @@ #include "src/core/iomgr/endpoint_pair.h" #include "src/core/iomgr/iomgr.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" #include "src/core/surface/server.h" #include "src/core/transport/chttp2_transport.h" #include @@ -56,12 +55,12 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static grpc_transport_setup_result server_setup_transport( +static void server_setup_transport( void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; - return grpc_server_setup_transport(f->server, transport, extra_filters, + grpc_server_setup_transport(f->server, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), mdctx, grpc_server_get_channel_args(f->server)); } @@ -71,12 +70,11 @@ typedef struct { grpc_channel_args *client_args; } sp_client_setup; -static grpc_transport_setup_result client_setup_transport( +static void client_setup_transport( void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { sp_client_setup *cs = ts; - const grpc_channel_filter *filters[] = {&grpc_client_surface_filter, - &grpc_http_client_filter, + const grpc_channel_filter *filters[] = {&grpc_http_client_filter, &grpc_connected_channel_filter}; size_t nfilters = sizeof(filters) / sizeof(*filters); grpc_channel *channel = grpc_channel_create_from_filters( @@ -84,7 +82,7 @@ static grpc_transport_setup_result client_setup_transport( cs->f->client = channel; - return grpc_connected_channel_bind_transport( + grpc_connected_channel_bind_transport( grpc_channel_get_channel_stack(channel), transport); } @@ -105,23 +103,29 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { grpc_endpoint_pair *sfd = f->fixture_data; + grpc_transport *transport; + grpc_mdctx *mdctx = grpc_mdctx_create(); sp_client_setup cs; cs.client_args = client_args; cs.f = f; - grpc_create_chttp2_transport(client_setup_transport, &cs, client_args, - sfd->client, NULL, 0, grpc_mdctx_create(), 1); + transport = grpc_create_chttp2_transport(client_args, + sfd->client, NULL, 0, mdctx, 1); + client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); } static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { grpc_endpoint_pair *sfd = f->fixture_data; + grpc_mdctx *mdctx = grpc_mdctx_create(); + grpc_transport *transport; GPR_ASSERT(!f->server); f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - grpc_create_chttp2_transport(server_setup_transport, f, server_args, - sfd->server, NULL, 0, grpc_mdctx_create(), 0); + transport = grpc_create_chttp2_transport(server_args, + sfd->server, NULL, 0, mdctx, 0); + server_setup_transport(f, transport, mdctx); } static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c index ac8b5eb86d8..d53a49edbfe 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c @@ -42,7 +42,6 @@ #include "src/core/iomgr/endpoint_pair.h" #include "src/core/iomgr/iomgr.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" #include "src/core/surface/server.h" #include "src/core/transport/chttp2_transport.h" #include @@ -56,12 +55,12 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static grpc_transport_setup_result server_setup_transport( +static void server_setup_transport( void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; - return grpc_server_setup_transport(f->server, transport, extra_filters, + grpc_server_setup_transport(f->server, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), mdctx, grpc_server_get_channel_args(f->server)); } @@ -71,12 +70,11 @@ typedef struct { grpc_channel_args *client_args; } sp_client_setup; -static grpc_transport_setup_result client_setup_transport( +static void client_setup_transport( void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { sp_client_setup *cs = ts; - const grpc_channel_filter *filters[] = {&grpc_client_surface_filter, - &grpc_http_client_filter, + const grpc_channel_filter *filters[] = {&grpc_http_client_filter, &grpc_connected_channel_filter}; size_t nfilters = sizeof(filters) / sizeof(*filters); grpc_channel *channel = grpc_channel_create_from_filters( @@ -84,7 +82,7 @@ static grpc_transport_setup_result client_setup_transport( cs->f->client = channel; - return grpc_connected_channel_bind_transport( + grpc_connected_channel_bind_transport( grpc_channel_get_channel_stack(channel), transport); } @@ -105,23 +103,29 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { grpc_endpoint_pair *sfd = f->fixture_data; + grpc_transport *transport; + grpc_mdctx *mdctx = grpc_mdctx_create(); sp_client_setup cs; cs.client_args = client_args; cs.f = f; - grpc_create_chttp2_transport(client_setup_transport, &cs, client_args, - sfd->client, NULL, 0, grpc_mdctx_create(), 1); + transport = grpc_create_chttp2_transport(client_args, + sfd->client, NULL, 0, mdctx, 1); + client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); } static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { grpc_endpoint_pair *sfd = f->fixture_data; + grpc_mdctx *mdctx = grpc_mdctx_create(); + grpc_transport *transport; GPR_ASSERT(!f->server); f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - grpc_create_chttp2_transport(server_setup_transport, f, server_args, - sfd->server, NULL, 0, grpc_mdctx_create(), 0); + transport = grpc_create_chttp2_transport(server_args, + sfd->server, NULL, 0, mdctx, 0); + server_setup_transport(f, transport, mdctx); } static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c index e160812fa33..c63d8f3fe98 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c @@ -43,7 +43,6 @@ #include "src/core/iomgr/iomgr.h" #include "src/core/support/env.h" #include "src/core/surface/channel.h" -#include "src/core/surface/client.h" #include "src/core/surface/server.h" #include "src/core/transport/chttp2_transport.h" #include @@ -57,12 +56,12 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static grpc_transport_setup_result server_setup_transport( +static void server_setup_transport( void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; - return grpc_server_setup_transport(f->server, transport, extra_filters, + grpc_server_setup_transport(f->server, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), mdctx, grpc_server_get_channel_args(f->server)); } @@ -72,12 +71,11 @@ typedef struct { grpc_channel_args *client_args; } sp_client_setup; -static grpc_transport_setup_result client_setup_transport( +static void client_setup_transport( void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { sp_client_setup *cs = ts; - const grpc_channel_filter *filters[] = {&grpc_client_surface_filter, - &grpc_http_client_filter, + const grpc_channel_filter *filters[] = {&grpc_http_client_filter, &grpc_connected_channel_filter}; size_t nfilters = sizeof(filters) / sizeof(*filters); grpc_channel *channel = grpc_channel_create_from_filters( @@ -85,7 +83,7 @@ static grpc_transport_setup_result client_setup_transport( cs->f->client = channel; - return grpc_connected_channel_bind_transport( + grpc_connected_channel_bind_transport( grpc_channel_get_channel_stack(channel), transport); } @@ -106,23 +104,29 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { grpc_endpoint_pair *sfd = f->fixture_data; + grpc_transport *transport; + grpc_mdctx *mdctx = grpc_mdctx_create(); sp_client_setup cs; cs.client_args = client_args; cs.f = f; - grpc_create_chttp2_transport(client_setup_transport, &cs, client_args, - sfd->client, NULL, 0, grpc_mdctx_create(), 1); + transport = grpc_create_chttp2_transport(client_args, + sfd->client, NULL, 0, mdctx, 1); + client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); } static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { grpc_endpoint_pair *sfd = f->fixture_data; + grpc_mdctx *mdctx = grpc_mdctx_create(); + grpc_transport *transport; GPR_ASSERT(!f->server); f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - grpc_create_chttp2_transport(server_setup_transport, f, server_args, - sfd->server, NULL, 0, grpc_mdctx_create(), 0); + transport = grpc_create_chttp2_transport(server_args, + sfd->server, NULL, 0, mdctx, 0); + server_setup_transport(f, transport, mdctx); } static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index edc7c5d6fe7..0da1f388c59 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -802,6 +802,7 @@ src/core/client_config/resolver.h \ src/core/client_config/resolver_factory.h \ src/core/client_config/resolver_registry.h \ src/core/client_config/resolvers/dns_resolver.h \ +src/core/client_config/resolvers/unix_resolver_posix.h \ src/core/client_config/subchannel.h \ src/core/client_config/subchannel_factory.h \ src/core/client_config/uri_parser.h \ @@ -918,6 +919,7 @@ src/core/client_config/resolver.c \ src/core/client_config/resolver_factory.c \ src/core/client_config/resolver_registry.c \ src/core/client_config/resolvers/dns_resolver.c \ +src/core/client_config/resolvers/unix_resolver_posix.c \ src/core/client_config/subchannel.c \ src/core/client_config/subchannel_factory.c \ src/core/client_config/uri_parser.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 8dab263d7a6..ed5a86fb63c 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -8665,6 +8665,7 @@ "src/core/client_config/resolver_factory.h", "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", "src/core/client_config/uri_parser.h", @@ -8806,6 +8807,8 @@ "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.c", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.c", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.c", @@ -9111,6 +9114,7 @@ "src/core/client_config/resolver_factory.h", "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.h", "src/core/client_config/uri_parser.h", @@ -9235,6 +9239,8 @@ "src/core/client_config/resolver_registry.h", "src/core/client_config/resolvers/dns_resolver.c", "src/core/client_config/resolvers/dns_resolver.h", + "src/core/client_config/resolvers/unix_resolver_posix.c", + "src/core/client_config/resolvers/unix_resolver_posix.h", "src/core/client_config/subchannel.c", "src/core/client_config/subchannel.h", "src/core/client_config/subchannel_factory.c", diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 7354bbc2f6b..25ba0936a1d 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -191,6 +191,7 @@ + @@ -349,6 +350,8 @@ + + diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index 639fa7093ef..6148abe66eb 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -121,6 +121,9 @@ src\core\client_config\resolvers + + src\core\client_config\resolvers + src\core\client_config @@ -524,6 +527,9 @@ src\core\client_config\resolvers + + src\core\client_config\resolvers + src\core\client_config diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index 6ab4803dbc5..a7f06f0c9d6 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -173,6 +173,7 @@ + @@ -287,6 +288,8 @@ + + diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index a970a728c3f..cfb1d24c58c 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -55,6 +55,9 @@ src\core\client_config\resolvers + + src\core\client_config\resolvers + src\core\client_config @@ -407,6 +410,9 @@ src\core\client_config\resolvers + + src\core\client_config\resolvers + src\core\client_config From 08a1cf8f4fd747ab331393916bd5d9cc7f4804c1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 09:37:52 -0700 Subject: [PATCH 053/124] Use connectivity state tracking code in chttp2 transport --- BUILD | 12 ++-- Makefile | 4 +- build.json | 4 +- gRPC.podspec | 6 +- src/core/channel/client_channel.c | 2 +- .../client_config/lb_policies/pick_first.c | 2 +- src/core/client_config/subchannel.c | 2 +- src/core/transport/chttp2/internal.h | 6 +- src/core/transport/chttp2_transport.c | 55 +++++++------------ .../connectivity_state.c | 45 ++++++++------- .../connectivity_state.h | 23 +++++--- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/sources_and_headers.json | 12 ++-- vsprojects/grpc/grpc.vcxproj | 6 +- vsprojects/grpc/grpc.vcxproj.filters | 12 ++-- .../grpc_unsecure/grpc_unsecure.vcxproj | 6 +- .../grpc_unsecure.vcxproj.filters | 12 ++-- 17 files changed, 105 insertions(+), 108 deletions(-) rename src/core/{channel => transport}/connectivity_state.c (72%) rename src/core/{channel => transport}/connectivity_state.h (77%) diff --git a/BUILD b/BUILD index a21004c4ed2..a02295a6777 100644 --- a/BUILD +++ b/BUILD @@ -152,7 +152,6 @@ cc_library( "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -237,6 +236,7 @@ cc_library( "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.h", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.h", "src/core/transport/stream_op.h", "src/core/transport/transport.h", @@ -270,7 +270,6 @@ cc_library( "src/core/channel/channel_stack.c", "src/core/channel/client_channel.c", "src/core/channel/connected_channel.c", - "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", @@ -368,6 +367,7 @@ cc_library( "src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", + "src/core/transport/connectivity_state.c", "src/core/transport/metadata.c", "src/core/transport/stream_op.c", "src/core/transport/transport.c", @@ -404,7 +404,6 @@ cc_library( "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -489,6 +488,7 @@ cc_library( "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.h", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.h", "src/core/transport/stream_op.h", "src/core/transport/transport.h", @@ -500,7 +500,6 @@ cc_library( "src/core/channel/channel_stack.c", "src/core/channel/client_channel.c", "src/core/channel/connected_channel.c", - "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", @@ -598,6 +597,7 @@ cc_library( "src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", + "src/core/transport/connectivity_state.c", "src/core/transport/metadata.c", "src/core/transport/stream_op.c", "src/core/transport/transport.c", @@ -940,7 +940,6 @@ objc_library( "src/core/channel/channel_stack.c", "src/core/channel/client_channel.c", "src/core/channel/connected_channel.c", - "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", @@ -1038,6 +1037,7 @@ objc_library( "src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", + "src/core/transport/connectivity_state.c", "src/core/transport/metadata.c", "src/core/transport/stream_op.c", "src/core/transport/transport.c", @@ -1058,7 +1058,6 @@ objc_library( "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -1143,6 +1142,7 @@ objc_library( "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.h", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.h", "src/core/transport/stream_op.h", "src/core/transport/transport.h", diff --git a/Makefile b/Makefile index 87c36da6a3e..1038158524e 100644 --- a/Makefile +++ b/Makefile @@ -3024,7 +3024,6 @@ LIBGRPC_SRC = \ src/core/channel/channel_stack.c \ src/core/channel/client_channel.c \ src/core/channel/connected_channel.c \ - src/core/channel/connectivity_state.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ @@ -3122,6 +3121,7 @@ LIBGRPC_SRC = \ src/core/transport/chttp2/varint.c \ src/core/transport/chttp2/writing.c \ src/core/transport/chttp2_transport.c \ + src/core/transport/connectivity_state.c \ src/core/transport/metadata.c \ src/core/transport/stream_op.c \ src/core/transport/transport.c \ @@ -3284,7 +3284,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/channel/channel_stack.c \ src/core/channel/client_channel.c \ src/core/channel/connected_channel.c \ - src/core/channel/connectivity_state.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ @@ -3382,6 +3381,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/transport/chttp2/varint.c \ src/core/transport/chttp2/writing.c \ src/core/transport/chttp2_transport.c \ + src/core/transport/connectivity_state.c \ src/core/transport/metadata.c \ src/core/transport/stream_op.c \ src/core/transport/transport.c \ diff --git a/build.json b/build.json index 541d5a3dfc2..c77b7340bad 100644 --- a/build.json +++ b/build.json @@ -113,7 +113,6 @@ "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -198,6 +197,7 @@ "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.h", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.h", "src/core/transport/stream_op.h", "src/core/transport/transport.h", @@ -209,7 +209,6 @@ "src/core/channel/channel_stack.c", "src/core/channel/client_channel.c", "src/core/channel/connected_channel.c", - "src/core/channel/connectivity_state.c", "src/core/channel/http_client_filter.c", "src/core/channel/http_server_filter.c", "src/core/channel/noop_filter.c", @@ -307,6 +306,7 @@ "src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", + "src/core/transport/connectivity_state.c", "src/core/transport/metadata.c", "src/core/transport/stream_op.c", "src/core/transport/transport.c", diff --git a/gRPC.podspec b/gRPC.podspec index ed82732bd8b..a292056d56d 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -154,7 +154,6 @@ Pod::Spec.new do |s| 'src/core/channel/channel_stack.h', 'src/core/channel/client_channel.h', 'src/core/channel/connected_channel.h', - 'src/core/channel/connectivity_state.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', @@ -239,6 +238,7 @@ Pod::Spec.new do |s| 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', + 'src/core/transport/connectivity_state.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', @@ -279,7 +279,6 @@ Pod::Spec.new do |s| 'src/core/channel/channel_stack.c', 'src/core/channel/client_channel.c', 'src/core/channel/connected_channel.c', - 'src/core/channel/connectivity_state.c', 'src/core/channel/http_client_filter.c', 'src/core/channel/http_server_filter.c', 'src/core/channel/noop_filter.c', @@ -377,6 +376,7 @@ Pod::Spec.new do |s| 'src/core/transport/chttp2/varint.c', 'src/core/transport/chttp2/writing.c', 'src/core/transport/chttp2_transport.c', + 'src/core/transport/connectivity_state.c', 'src/core/transport/metadata.c', 'src/core/transport/stream_op.c', 'src/core/transport/transport.c', @@ -412,7 +412,6 @@ Pod::Spec.new do |s| 'src/core/channel/channel_stack.h', 'src/core/channel/client_channel.h', 'src/core/channel/connected_channel.h', - 'src/core/channel/connectivity_state.h', 'src/core/channel/context.h', 'src/core/channel/http_client_filter.h', 'src/core/channel/http_server_filter.h', @@ -497,6 +496,7 @@ Pod::Spec.new do |s| 'src/core/transport/chttp2/timeout_encoding.h', 'src/core/transport/chttp2/varint.h', 'src/core/transport/chttp2_transport.h', + 'src/core/transport/connectivity_state.h', 'src/core/transport/metadata.h', 'src/core/transport/stream_op.h', 'src/core/transport/transport.h', diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index b33ef7842fb..e2f8debdfad 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -38,10 +38,10 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/connected_channel.h" -#include "src/core/channel/connectivity_state.h" #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/pollset_set.h" #include "src/core/support/string.h" +#include "src/core/transport/connectivity_state.h" #include #include #include diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index 9d6c264e37c..cdc7e751401 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -36,7 +36,7 @@ #include #include -#include "src/core/channel/connectivity_state.h" +#include "src/core/transport/connectivity_state.h" typedef struct pending_pick { struct pending_pick *next; diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index b4da9cda3f3..2f5843b2a4d 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -39,7 +39,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/connected_channel.h" -#include "src/core/channel/connectivity_state.h" +#include "src/core/transport/connectivity_state.h" typedef struct { /* all fields protected by subchannel->mu */ diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h index 93235aef552..7e2e75f97d2 100644 --- a/src/core/transport/chttp2/internal.h +++ b/src/core/transport/chttp2/internal.h @@ -34,7 +34,6 @@ #ifndef GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H #define GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H -#include "src/core/transport/transport_impl.h" #include "src/core/iomgr/endpoint.h" #include "src/core/transport/chttp2/frame.h" #include "src/core/transport/chttp2/frame_data.h" @@ -47,6 +46,8 @@ #include "src/core/transport/chttp2/incoming_metadata.h" #include "src/core/transport/chttp2/stream_encoder.h" #include "src/core/transport/chttp2/stream_map.h" +#include "src/core/transport/connectivity_state.h" +#include "src/core/transport/transport_impl.h" typedef struct grpc_chttp2_transport grpc_chttp2_transport; typedef struct grpc_chttp2_stream grpc_chttp2_stream; @@ -335,8 +336,7 @@ struct grpc_chttp2_transport { void *accept_stream_user_data; /** connectivity tracking */ - grpc_iomgr_closure *on_connectivity_changed; - grpc_connectivity_state *connectivity; + grpc_connectivity_state_tracker state_tracker; } channel_callback; }; diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 11dd60bbb9c..8f909dff374 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -37,18 +37,19 @@ #include #include +#include +#include +#include +#include +#include + #include "src/core/profiling/timers.h" #include "src/core/support/string.h" #include "src/core/transport/chttp2/http2_errors.h" +#include "src/core/transport/chttp2/internal.h" #include "src/core/transport/chttp2/status_conversion.h" #include "src/core/transport/chttp2/timeout_encoding.h" -#include "src/core/transport/chttp2/internal.h" #include "src/core/transport/transport_impl.h" -#include -#include -#include -#include -#include /* #define REFCOUNTING_DEBUG */ @@ -81,7 +82,6 @@ static const grpc_transport_vtable vtable; static void lock(grpc_chttp2_transport *t); static void unlock(grpc_chttp2_transport *t); -static void unlock_check_channel_callbacks(grpc_chttp2_transport *t); static void unlock_check_read_write_state(grpc_chttp2_transport *t); /* forward declarations of various callbacks that we'll build closures around */ @@ -149,6 +149,7 @@ static void destruct_transport(grpc_chttp2_transport *t) { grpc_chttp2_stream_map_destroy(&t->parsing_stream_map); grpc_chttp2_stream_map_destroy(&t->new_stream_map); + grpc_connectivity_state_destroy(&t->channel_callback.state_tracker); gpr_mu_unlock(&t->mu); gpr_mu_destroy(&t->mu); @@ -229,6 +230,8 @@ static void init_transport(grpc_chttp2_transport *t, t->parsing.deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0; t->writing.is_client = is_client; + grpc_connectivity_state_init(&t->channel_callback.state_tracker, + GRPC_CHANNEL_READY); gpr_slice_buffer_init(&t->global.qbuf); @@ -325,6 +328,8 @@ static void destroy_transport(grpc_transport *gt) { static void close_transport_locked(grpc_chttp2_transport *t) { if (!t->closed) { t->closed = 1; + grpc_connectivity_state_set(&t->channel_callback.state_tracker, + GRPC_CHANNEL_FATAL_FAILURE); if (t->ep) { grpc_endpoint_shutdown(t->ep); } @@ -445,8 +450,6 @@ static void unlock(grpc_chttp2_transport *t) { REF_TRANSPORT(t, "writing"); grpc_chttp2_schedule_closure(&t->global, &t->writing_action, 1); } - /* unlock_check_parser(t); */ - unlock_check_channel_callbacks(t); run_closures = t->global.pending_closures; t->global.pending_closures = NULL; @@ -520,6 +523,9 @@ void grpc_chttp2_add_incoming_goaway( gpr_free(msg); gpr_slice_unref(goaway_text); transport_global->seen_goaway = 1; + grpc_connectivity_state_set( + &TRANSPORT_FROM_GLOBAL(transport_global)->channel_callback.state_tracker, + GRPC_CHANNEL_FATAL_FAILURE); } static void maybe_start_some_streams( @@ -544,9 +550,9 @@ static void maybe_start_some_streams( transport_global->next_stream_id += 2; if (transport_global->next_stream_id >= MAX_CLIENT_STREAM_ID) { - grpc_chttp2_add_incoming_goaway( - transport_global, GRPC_CHTTP2_NO_ERROR, - gpr_slice_from_copied_string("Exceeded sequence number limit")); + grpc_connectivity_state_set(&TRANSPORT_FROM_GLOBAL(transport_global) + ->channel_callback.state_tracker, + GRPC_CHANNEL_TRANSIENT_FAILURE); } stream_global->outgoing_window = @@ -669,10 +675,9 @@ static void perform_transport_op(grpc_transport *gt, grpc_transport_op *op) { } if (op->on_connectivity_state_change) { - GPR_ASSERT(t->channel_callback.on_connectivity_changed == NULL); - t->channel_callback.on_connectivity_changed = - op->on_connectivity_state_change; - t->channel_callback.connectivity = op->connectivity_state; + grpc_connectivity_state_notify_on_state_change( + &t->channel_callback.state_tracker, op->connectivity_state, + op->on_connectivity_state_change); } if (op->send_goaway) { @@ -928,24 +933,6 @@ static void reading_action(void *pt, int iomgr_success_ignored) { * CALLBACK LOOP */ -static void unlock_check_channel_callbacks(grpc_chttp2_transport *t) { - if (t->channel_callback.on_connectivity_changed != NULL) { - grpc_connectivity_state current; - if (t->closed || t->global.seen_goaway) { - current = GRPC_CHANNEL_FATAL_FAILURE; - } else { - current = GRPC_CHANNEL_READY; - } - if (current != *t->channel_callback.connectivity) { - *t->channel_callback.connectivity = current; - grpc_chttp2_schedule_closure( - &t->global, t->channel_callback.on_connectivity_changed, 1); - t->channel_callback.on_connectivity_changed = NULL; - t->channel_callback.connectivity = NULL; - } - } -} - void grpc_chttp2_schedule_closure( grpc_chttp2_transport_global *transport_global, grpc_iomgr_closure *closure, int success) { diff --git a/src/core/channel/connectivity_state.c b/src/core/transport/connectivity_state.c similarity index 72% rename from src/core/channel/connectivity_state.c rename to src/core/transport/connectivity_state.c index 0ee268ee59a..5cbd67ef3c8 100644 --- a/src/core/channel/connectivity_state.c +++ b/src/core/transport/connectivity_state.c @@ -31,52 +31,57 @@ * */ -#include "src/core/channel/connectivity_state.h" +#include "src/core/transport/connectivity_state.h" #include -void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state init_state) { - tracker->current_state = init_state; - tracker->watchers = NULL; +void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, + grpc_connectivity_state init_state) { + tracker->current_state = init_state; + tracker->watchers = NULL; } void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker) { grpc_connectivity_state_watcher *w; while ((w = tracker->watchers)) { - tracker->watchers = w->next; + tracker->watchers = w->next; - if (GRPC_CHANNEL_FATAL_FAILURE != *w->current) { - *w->current = GRPC_CHANNEL_FATAL_FAILURE; - grpc_iomgr_add_callback(w->notify); - } else { - grpc_iomgr_add_delayed_callback(w->notify, 0); - } - gpr_free(w); + if (GRPC_CHANNEL_FATAL_FAILURE != *w->current) { + *w->current = GRPC_CHANNEL_FATAL_FAILURE; + grpc_iomgr_add_callback(w->notify); + } else { + grpc_iomgr_add_delayed_callback(w->notify, 0); + } + gpr_free(w); } } -grpc_connectivity_state grpc_connectivity_state_check(grpc_connectivity_state_tracker *tracker) { - return tracker->current_state; +grpc_connectivity_state grpc_connectivity_state_check( + grpc_connectivity_state_tracker *tracker) { + return tracker->current_state; } -int grpc_connectivity_state_notify_on_state_change(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, grpc_iomgr_closure *notify) { +int grpc_connectivity_state_notify_on_state_change( + grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, + grpc_iomgr_closure *notify) { if (tracker->current_state != *current) { *current = tracker->current_state; grpc_iomgr_add_callback(notify); } else { - grpc_connectivity_state_watcher *w = gpr_malloc(sizeof(*w)); - w->current = current; - w->notify = notify; + grpc_connectivity_state_watcher *w = gpr_malloc(sizeof(*w)); + w->current = current; + w->notify = notify; w->next = tracker->watchers; tracker->watchers = w; } return tracker->current_state == GRPC_CHANNEL_IDLE; } -void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state) { +void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, + grpc_connectivity_state state) { grpc_connectivity_state_watcher *new = NULL; grpc_connectivity_state_watcher *w; if (tracker->current_state == state) { - return; + return; } tracker->current_state = state; while ((w = tracker->watchers)) { diff --git a/src/core/channel/connectivity_state.h b/src/core/transport/connectivity_state.h similarity index 77% rename from src/core/channel/connectivity_state.h rename to src/core/transport/connectivity_state.h index ebc1acc5592..9a8c57525f0 100644 --- a/src/core/channel/connectivity_state.h +++ b/src/core/transport/connectivity_state.h @@ -31,14 +31,14 @@ * */ -#ifndef GRPC_INTERNAL_CORE_CHANNEL_CONNECTIVITY_STATE_H -#define GRPC_INTERNAL_CORE_CHANNEL_CONNECTIVITY_STATE_H +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CONNECTIVITY_STATE_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CONNECTIVITY_STATE_H #include #include "src/core/iomgr/iomgr.h" typedef struct grpc_connectivity_state_watcher { - /** we keep watchers in a linked list */ + /** we keep watchers in a linked list */ struct grpc_connectivity_state_watcher *next; /** closure to notify on change */ grpc_iomgr_closure *notify; @@ -47,20 +47,25 @@ typedef struct grpc_connectivity_state_watcher { } grpc_connectivity_state_watcher; typedef struct { - /** current connectivity state */ + /** current connectivity state */ grpc_connectivity_state current_state; /** all our watchers */ grpc_connectivity_state_watcher *watchers; } grpc_connectivity_state_tracker; -void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state init_state); +void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, + grpc_connectivity_state init_state); void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker); -void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state); +void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, + grpc_connectivity_state state); -grpc_connectivity_state grpc_connectivity_state_check(grpc_connectivity_state_tracker *tracker); +grpc_connectivity_state grpc_connectivity_state_check( + grpc_connectivity_state_tracker *tracker); /** Return 1 if the channel should start connecting, 0 otherwise */ -int grpc_connectivity_state_notify_on_state_change(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, grpc_iomgr_closure *notify); +int grpc_connectivity_state_notify_on_state_change( + grpc_connectivity_state_tracker *tracker, grpc_connectivity_state *current, + grpc_iomgr_closure *notify); -#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONNECTIVITY_STATE_H */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CONNECTIVITY_STATE_H */ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 0da1f388c59..e2701eca3a2 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -789,7 +789,6 @@ src/core/channel/channel_args.h \ src/core/channel/channel_stack.h \ src/core/channel/client_channel.h \ src/core/channel/connected_channel.h \ -src/core/channel/connectivity_state.h \ src/core/channel/context.h \ src/core/channel/http_client_filter.h \ src/core/channel/http_server_filter.h \ @@ -874,6 +873,7 @@ src/core/transport/chttp2/stream_map.h \ src/core/transport/chttp2/timeout_encoding.h \ src/core/transport/chttp2/varint.h \ src/core/transport/chttp2_transport.h \ +src/core/transport/connectivity_state.h \ src/core/transport/metadata.h \ src/core/transport/stream_op.h \ src/core/transport/transport.h \ @@ -907,7 +907,6 @@ src/core/channel/channel_args.c \ src/core/channel/channel_stack.c \ src/core/channel/client_channel.c \ src/core/channel/connected_channel.c \ -src/core/channel/connectivity_state.c \ src/core/channel/http_client_filter.c \ src/core/channel/http_server_filter.c \ src/core/channel/noop_filter.c \ @@ -1005,6 +1004,7 @@ src/core/transport/chttp2/timeout_encoding.c \ src/core/transport/chttp2/varint.c \ src/core/transport/chttp2/writing.c \ src/core/transport/chttp2_transport.c \ +src/core/transport/connectivity_state.c \ src/core/transport/metadata.c \ src/core/transport/stream_op.c \ src/core/transport/transport.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 9bb9a4a397b..3a858277fa8 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -8680,7 +8680,6 @@ "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -8777,6 +8776,7 @@ "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.h", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.h", "src/core/transport/stream_op.h", "src/core/transport/transport.h", @@ -8810,8 +8810,6 @@ "src/core/channel/client_channel.h", "src/core/channel/connected_channel.c", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.c", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.h", @@ -9025,6 +9023,8 @@ "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.c", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.c", "src/core/transport/metadata.h", "src/core/transport/stream_op.c", @@ -9129,7 +9129,6 @@ "src/core/channel/channel_stack.h", "src/core/channel/client_channel.h", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.h", "src/core/channel/http_server_filter.h", @@ -9214,6 +9213,7 @@ "src/core/transport/chttp2/timeout_encoding.h", "src/core/transport/chttp2/varint.h", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.h", "src/core/transport/stream_op.h", "src/core/transport/transport.h", @@ -9242,8 +9242,6 @@ "src/core/channel/client_channel.h", "src/core/channel/connected_channel.c", "src/core/channel/connected_channel.h", - "src/core/channel/connectivity_state.c", - "src/core/channel/connectivity_state.h", "src/core/channel/context.h", "src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.h", @@ -9426,6 +9424,8 @@ "src/core/transport/chttp2/writing.c", "src/core/transport/chttp2_transport.c", "src/core/transport/chttp2_transport.h", + "src/core/transport/connectivity_state.c", + "src/core/transport/connectivity_state.h", "src/core/transport/metadata.c", "src/core/transport/metadata.h", "src/core/transport/stream_op.c", diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index 25ba0936a1d..14ddf95f81f 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -178,7 +178,6 @@ - @@ -263,6 +262,7 @@ + @@ -326,8 +326,6 @@ - - @@ -522,6 +520,8 @@ + + diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index 6148abe66eb..591fe1bb034 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -85,9 +85,6 @@ src\core\channel - - src\core\channel - src\core\channel @@ -379,6 +376,9 @@ src\core\transport + + src\core\transport + src\core\transport @@ -488,9 +488,6 @@ src\core\channel - - src\core\channel - src\core\channel @@ -743,6 +740,9 @@ src\core\transport + + src\core\transport + src\core\transport diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index a7f06f0c9d6..4ead6f8d98a 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -160,7 +160,6 @@ - @@ -245,6 +244,7 @@ + @@ -264,8 +264,6 @@ - - @@ -460,6 +458,8 @@ + + diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index cfb1d24c58c..45ca1f7c33b 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -19,9 +19,6 @@ src\core\channel - - src\core\channel - src\core\channel @@ -313,6 +310,9 @@ src\core\transport + + src\core\transport + src\core\transport @@ -371,9 +371,6 @@ src\core\channel - - src\core\channel - src\core\channel @@ -626,6 +623,9 @@ src\core\transport + + src\core\transport + src\core\transport From 4ab82d2c4dd6a21cf2a13662fb2efa9171efe104 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 09:40:33 -0700 Subject: [PATCH 054/124] clang-format --- src/core/client_config/connector.c | 9 +- src/core/client_config/connector.h | 12 +- .../client_config/lb_policies/pick_first.c | 52 +++-- src/core/client_config/lb_policy.c | 31 +-- src/core/client_config/lb_policy.h | 19 +- .../resolvers/unix_resolver_posix.c | 21 +- src/core/client_config/subchannel.c | 214 +++++++++--------- src/core/client_config/subchannel.h | 9 +- 8 files changed, 197 insertions(+), 170 deletions(-) diff --git a/src/core/client_config/connector.c b/src/core/client_config/connector.c index 9cc57ddf38c..a8cd5fc1490 100644 --- a/src/core/client_config/connector.c +++ b/src/core/client_config/connector.c @@ -41,10 +41,9 @@ void grpc_connector_unref(grpc_connector *connector) { connector->vtable->unref(connector); } -void grpc_connector_connect( - grpc_connector *connector, - const grpc_connect_in_args *in_args, - grpc_connect_out_args *out_args, - grpc_iomgr_closure *notify) { +void grpc_connector_connect(grpc_connector *connector, + const grpc_connect_in_args *in_args, + grpc_connect_out_args *out_args, + grpc_iomgr_closure *notify) { connector->vtable->connect(connector, in_args, out_args, notify); } diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h index 55c6e63129a..edcb10a36ec 100644 --- a/src/core/client_config/connector.h +++ b/src/core/client_config/connector.h @@ -72,16 +72,14 @@ struct grpc_connector_vtable { void (*unref)(grpc_connector *connector); void (*connect)(grpc_connector *connector, const grpc_connect_in_args *in_args, - grpc_connect_out_args *out_args, - grpc_iomgr_closure *notify); + grpc_connect_out_args *out_args, grpc_iomgr_closure *notify); }; void grpc_connector_ref(grpc_connector *connector); void grpc_connector_unref(grpc_connector *connector); -void grpc_connector_connect( - grpc_connector *connector, - const grpc_connect_in_args *in_args, - grpc_connect_out_args *out_args, - grpc_iomgr_closure *notify); +void grpc_connector_connect(grpc_connector *connector, + const grpc_connect_in_args *in_args, + grpc_connect_out_args *out_args, + grpc_iomgr_closure *notify); #endif diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index cdc7e751401..c94408200ba 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -74,7 +74,7 @@ typedef struct { } pick_first_lb_policy; void pf_destroy(grpc_lb_policy *pol) { - pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; size_t i; for (i = 0; i < p->num_subchannels; i++) { grpc_subchannel_unref(p->subchannels[i]); @@ -92,7 +92,7 @@ void pf_shutdown(grpc_lb_policy *pol) { void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, grpc_metadata_batch *initial_metadata, grpc_subchannel **target, grpc_iomgr_closure *on_complete) { - pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; pending_pick *pp; gpr_mu_lock(&p->mu); if (p->selected) { @@ -105,9 +105,12 @@ void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, p->checking_subchannel = 0; p->checking_connectivity = GRPC_CHANNEL_IDLE; GRPC_LB_POLICY_REF(pol, "pick_first_connectivity"); - grpc_subchannel_notify_on_state_change(p->subchannels[p->checking_subchannel], &p->checking_connectivity, &p->connectivity_changed); + grpc_subchannel_notify_on_state_change( + p->subchannels[p->checking_subchannel], &p->checking_connectivity, + &p->connectivity_changed); } - grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], pollset); + grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], + pollset); pp = gpr_malloc(sizeof(*pp)); pp->next = p->pending_picks; pp->pollset = pollset; @@ -121,14 +124,16 @@ void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, static void del_interested_parties_locked(pick_first_lb_policy *p) { pending_pick *pp; for (pp = p->pending_picks; pp; pp = pp->next) { - grpc_subchannel_del_interested_party(p->subchannels[p->checking_subchannel], pp->pollset); + grpc_subchannel_del_interested_party(p->subchannels[p->checking_subchannel], + pp->pollset); } } static void add_interested_parties_locked(pick_first_lb_policy *p) { pending_pick *pp; for (pp = p->pending_picks; pp; pp = pp->next) { - grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], pp->pollset); + grpc_subchannel_add_interested_party(p->subchannels[p->checking_subchannel], + pp->pollset); } } @@ -142,7 +147,8 @@ loop: switch (p->checking_connectivity) { case GRPC_CHANNEL_READY: p->selected = p->subchannels[p->checking_subchannel]; - GPR_ASSERT(grpc_subchannel_check_connectivity(p->selected) == GRPC_CHANNEL_READY); + GPR_ASSERT(grpc_subchannel_check_connectivity(p->selected) == + GRPC_CHANNEL_READY); while ((pp = p->pending_picks)) { p->pending_picks = pp->next; *pp->target = p->selected; @@ -154,19 +160,25 @@ loop: break; case GRPC_CHANNEL_TRANSIENT_FAILURE: del_interested_parties_locked(p); - p->checking_subchannel = (p->checking_subchannel + 1) % p->num_subchannels; - p->checking_connectivity = grpc_subchannel_check_connectivity(p->subchannels[p->checking_subchannel]); + p->checking_subchannel = + (p->checking_subchannel + 1) % p->num_subchannels; + p->checking_connectivity = grpc_subchannel_check_connectivity( + p->subchannels[p->checking_subchannel]); add_interested_parties_locked(p); goto loop; case GRPC_CHANNEL_CONNECTING: case GRPC_CHANNEL_IDLE: - grpc_subchannel_notify_on_state_change(p->subchannels[p->checking_subchannel], &p->checking_connectivity, &p->connectivity_changed); + grpc_subchannel_notify_on_state_change( + p->subchannels[p->checking_subchannel], &p->checking_connectivity, + &p->connectivity_changed); break; case GRPC_CHANNEL_FATAL_FAILURE: del_interested_parties_locked(p); - GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel], p->subchannels[p->num_subchannels - 1]); + GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel], + p->subchannels[p->num_subchannels - 1]); p->checking_subchannel %= p->num_subchannels; - p->checking_connectivity = grpc_subchannel_check_connectivity(p->subchannels[p->checking_subchannel]); + p->checking_connectivity = grpc_subchannel_check_connectivity( + p->subchannels[p->checking_subchannel]); p->num_subchannels--; grpc_subchannel_unref(p->subchannels[p->num_subchannels]); add_interested_parties_locked(p); @@ -184,7 +196,7 @@ loop: } static void pf_broadcast(grpc_lb_policy *pol, grpc_transport_op *op) { - pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; size_t i; size_t n; grpc_subchannel **subchannels; @@ -206,7 +218,7 @@ static void pf_broadcast(grpc_lb_policy *pol, grpc_transport_op *op) { } static grpc_connectivity_state pf_check_connectivity(grpc_lb_policy *pol) { - pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; grpc_connectivity_state st; gpr_mu_lock(&p->mu); st = grpc_connectivity_state_check(&p->state_tracker); @@ -214,15 +226,19 @@ static grpc_connectivity_state pf_check_connectivity(grpc_lb_policy *pol) { return st; } -static void pf_notify_on_state_change(grpc_lb_policy *pol, grpc_connectivity_state *current, grpc_iomgr_closure *notify) { - pick_first_lb_policy *p = (pick_first_lb_policy*)pol; +static void pf_notify_on_state_change(grpc_lb_policy *pol, + grpc_connectivity_state *current, + grpc_iomgr_closure *notify) { + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; gpr_mu_lock(&p->mu); - grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current, notify); + grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current, + notify); gpr_mu_unlock(&p->mu); } static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = { - pf_destroy, pf_shutdown, pf_pick, pf_broadcast, pf_check_connectivity, pf_notify_on_state_change}; + pf_destroy, pf_shutdown, pf_pick, + pf_broadcast, pf_check_connectivity, pf_notify_on_state_change}; grpc_lb_policy *grpc_create_pick_first_lb_policy(grpc_subchannel **subchannels, size_t num_subchannels) { diff --git a/src/core/client_config/lb_policy.c b/src/core/client_config/lb_policy.c index dfe21cf443a..6d1c788742b 100644 --- a/src/core/client_config/lb_policy.c +++ b/src/core/client_config/lb_policy.c @@ -33,33 +33,34 @@ #include "src/core/client_config/lb_policy.h" -void grpc_lb_policy_init(grpc_lb_policy *policy, const grpc_lb_policy_vtable *vtable) { - policy->vtable = vtable; - gpr_ref_init(&policy->refs, 1); +void grpc_lb_policy_init(grpc_lb_policy *policy, + const grpc_lb_policy_vtable *vtable) { + policy->vtable = vtable; + gpr_ref_init(&policy->refs, 1); } #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG -void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line, const char *reason) { +void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line, + const char *reason) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "LB_POLICY:%p ref %d -> %d %s", - policy, (int)policy->refs.count, (int)policy->refs.count + 1, - reason); + policy, (int)policy->refs.count, (int)policy->refs.count + 1, reason); #else -void grpc_lb_policy_ref(grpc_lb_policy *policy) { +void grpc_lb_policy_ref(grpc_lb_policy *policy) { #endif - gpr_ref(&policy->refs); + gpr_ref(&policy->refs); } #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG -void grpc_lb_policy_unref(grpc_lb_policy *policy, const char *file, int line, const char *reason) { +void grpc_lb_policy_unref(grpc_lb_policy *policy, const char *file, int line, + const char *reason) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "LB_POLICY:%p unref %d -> %d %s", - policy, (int)policy->refs.count, (int)policy->refs.count - 1, - reason); + policy, (int)policy->refs.count, (int)policy->refs.count - 1, reason); #else void grpc_lb_policy_unref(grpc_lb_policy *policy) { #endif - if (gpr_unref(&policy->refs)) { - policy->vtable->destroy(policy); - } + if (gpr_unref(&policy->refs)) { + policy->vtable->destroy(policy); + } } void grpc_lb_policy_shutdown(grpc_lb_policy *policy) { @@ -74,5 +75,5 @@ void grpc_lb_policy_pick(grpc_lb_policy *policy, grpc_pollset *pollset, } void grpc_lb_policy_broadcast(grpc_lb_policy *policy, grpc_transport_op *op) { - policy->vtable->broadcast(policy, op); + policy->vtable->broadcast(policy, op); } diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h index 717f26af652..a468f761cc9 100644 --- a/src/core/client_config/lb_policy.h +++ b/src/core/client_config/lb_policy.h @@ -67,14 +67,20 @@ struct grpc_lb_policy_vtable { /** call notify when the connectivity state of a channel changes from *state. Updates *state with the new state of the policy */ - void (*notify_on_state_change)(grpc_lb_policy *policy, grpc_connectivity_state *state, grpc_iomgr_closure *closure); + void (*notify_on_state_change)(grpc_lb_policy *policy, + grpc_connectivity_state *state, + grpc_iomgr_closure *closure); }; #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG -#define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p), __FILE__, __LINE__, (r)) -#define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p), __FILE__, __LINE__, (r)) -void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line, const char *reason); -void grpc_lb_policy_unref(grpc_lb_policy *policy, const char *file, int line, const char *reason); +#define GRPC_LB_POLICY_REF(p, r) \ + grpc_lb_policy_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_LB_POLICY_UNREF(p, r) \ + grpc_lb_policy_unref((p), __FILE__, __LINE__, (r)) +void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line, + const char *reason); +void grpc_lb_policy_unref(grpc_lb_policy *policy, const char *file, int line, + const char *reason); #else #define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p)) #define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p)) @@ -83,7 +89,8 @@ void grpc_lb_policy_unref(grpc_lb_policy *policy); #endif /** called by concrete implementations to initialize the base struct */ -void grpc_lb_policy_init(grpc_lb_policy *policy, const grpc_lb_policy_vtable *vtable); +void grpc_lb_policy_init(grpc_lb_policy *policy, + const grpc_lb_policy_vtable *vtable); /** Start shutting down (fail any pending picks) */ void grpc_lb_policy_shutdown(grpc_lb_policy *policy); diff --git a/src/core/client_config/resolvers/unix_resolver_posix.c b/src/core/client_config/resolvers/unix_resolver_posix.c index 3dedf94357c..f7498548b11 100644 --- a/src/core/client_config/resolvers/unix_resolver_posix.c +++ b/src/core/client_config/resolvers/unix_resolver_posix.c @@ -79,10 +79,10 @@ static void unix_ref(grpc_resolver *r); static void unix_unref(grpc_resolver *r); static void unix_shutdown(grpc_resolver *r); static void unix_channel_saw_error(grpc_resolver *r, - struct sockaddr *failing_address, - int failing_address_len); + struct sockaddr *failing_address, + int failing_address_len); static void unix_next(grpc_resolver *r, grpc_client_config **target_config, - grpc_iomgr_closure *on_complete); + grpc_iomgr_closure *on_complete); static const grpc_resolver_vtable unix_resolver_vtable = { unix_ref, unix_unref, unix_shutdown, unix_channel_saw_error, unix_next}; @@ -112,12 +112,11 @@ static void unix_shutdown(grpc_resolver *resolver) { } static void unix_channel_saw_error(grpc_resolver *resolver, struct sockaddr *sa, - int len) { -} + int len) {} static void unix_next(grpc_resolver *resolver, - grpc_client_config **target_config, - grpc_iomgr_closure *on_complete) { + grpc_client_config **target_config, + grpc_iomgr_closure *on_complete) { unix_resolver *r = (unix_resolver *)resolver; gpr_mu_lock(&r->mu); GPR_ASSERT(!r->next_completion); @@ -136,9 +135,10 @@ static void unix_maybe_finish_next_locked(unix_resolver *r) { if (r->next_completion != NULL && !r->published) { cfg = grpc_client_config_create(); memset(&args, 0, sizeof(args)); - args.addr = (struct sockaddr *) &r->addr; + args.addr = (struct sockaddr *)&r->addr; args.addr_len = r->addr_len; - subchannel = grpc_subchannel_factory_create_subchannel(r->subchannel_factory, &args); + subchannel = + grpc_subchannel_factory_create_subchannel(r->subchannel_factory, &args); lb_policy = r->lb_policy_factory(&subchannel, 1); grpc_client_config_set_lb_policy(cfg, lb_policy); GRPC_LB_POLICY_UNREF(lb_policy, "unix"); @@ -194,8 +194,7 @@ static void unix_factory_unref(grpc_resolver_factory *factory) {} static grpc_resolver *unix_factory_create_resolver( grpc_resolver_factory *factory, grpc_uri *uri, grpc_subchannel_factory *subchannel_factory) { - return unix_create(uri, grpc_create_pick_first_lb_policy, - subchannel_factory); + return unix_create(uri, grpc_create_pick_first_lb_policy, subchannel_factory); } static const grpc_resolver_factory_vtable unix_factory_vtable = { diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 2f5843b2a4d..c770cb3b20f 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -42,10 +42,10 @@ #include "src/core/transport/connectivity_state.h" typedef struct { - /* all fields protected by subchannel->mu */ - /** refcount */ - int refs; - /** parent subchannel */ + /* all fields protected by subchannel->mu */ + /** refcount */ + int refs; + /** parent subchannel */ grpc_subchannel *subchannel; } connection; @@ -103,7 +103,8 @@ struct grpc_subchannel_call { #define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack *)((call) + 1)) #define CHANNEL_STACK_FROM_CONNECTION(con) ((grpc_channel_stack *)((con) + 1)) -static grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op); +static grpc_subchannel_call *create_call(connection *con, + grpc_transport_stream_op *initial_op); static void connectivity_state_changed_locked(grpc_subchannel *c); static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); static gpr_timespec compute_connect_deadline(grpc_subchannel *c); @@ -112,7 +113,8 @@ static void subchannel_connected(void *subchannel, int iomgr_success); static void subchannel_ref_locked(grpc_subchannel *c); static int subchannel_unref_locked(grpc_subchannel *c) GRPC_MUST_USE_RESULT; static void connection_ref_locked(connection *c); -static grpc_subchannel *connection_unref_locked(connection *c) GRPC_MUST_USE_RESULT; +static grpc_subchannel *connection_unref_locked(connection *c) + GRPC_MUST_USE_RESULT; static void subchannel_destroy(grpc_subchannel *c); /* @@ -120,58 +122,55 @@ static void subchannel_destroy(grpc_subchannel *c); */ static void connection_destroy(connection *c) { - GPR_ASSERT(c->refs == 0); - grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CONNECTION(c)); + GPR_ASSERT(c->refs == 0); + grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CONNECTION(c)); gpr_free(c); } -static void connection_ref_locked(connection *c) { - subchannel_ref_locked(c->subchannel); - ++c->refs; +static void connection_ref_locked(connection *c) { + subchannel_ref_locked(c->subchannel); + ++c->refs; } static grpc_subchannel *connection_unref_locked(connection *c) { - grpc_subchannel *destroy = NULL; - if (subchannel_unref_locked(c->subchannel)) { - destroy = c->subchannel; - } + grpc_subchannel *destroy = NULL; + if (subchannel_unref_locked(c->subchannel)) { + destroy = c->subchannel; + } if (--c->refs == 0 && c->subchannel->active != c) { - connection_destroy(c); + connection_destroy(c); } return destroy; } - /* * grpc_subchannel implementation */ -static void subchannel_ref_locked(grpc_subchannel *c) { - ++c->refs; -} +static void subchannel_ref_locked(grpc_subchannel *c) { ++c->refs; } static int subchannel_unref_locked(grpc_subchannel *c) { - return --c->refs == 0; + return --c->refs == 0; } void grpc_subchannel_ref(grpc_subchannel *c) { - gpr_mu_lock(&c->mu); - subchannel_ref_locked(c); - gpr_mu_unlock(&c->mu); + gpr_mu_lock(&c->mu); + subchannel_ref_locked(c); + gpr_mu_unlock(&c->mu); } void grpc_subchannel_unref(grpc_subchannel *c) { - int destroy; - gpr_mu_lock(&c->mu); - destroy = subchannel_unref_locked(c); - gpr_mu_unlock(&c->mu); - if (destroy) subchannel_destroy(c); + int destroy; + gpr_mu_lock(&c->mu); + destroy = subchannel_unref_locked(c); + gpr_mu_unlock(&c->mu); + if (destroy) subchannel_destroy(c); } static void subchannel_destroy(grpc_subchannel *c) { - if (c->active != NULL) { - connection_destroy(c->active); - } + if (c->active != NULL) { + connection_destroy(c->active); + } gpr_free(c->filters); grpc_channel_args_destroy(c->args); gpr_free(c->addr); @@ -216,16 +215,17 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, } static void start_connect(grpc_subchannel *c) { - grpc_connect_in_args args; + grpc_connect_in_args args; - args.interested_parties = &c->pollset_set; - args.addr = c->addr; - args.addr_len = c->addr_len; - args.deadline = compute_connect_deadline(c); - args.channel_args = c->args; - args.metadata_context = c->mdctx; + args.interested_parties = &c->pollset_set; + args.addr = c->addr; + args.addr_len = c->addr_len; + args.deadline = compute_connect_deadline(c); + args.channel_args = c->args; + args.metadata_context = c->mdctx; - grpc_connector_connect(c->connector, &args, &c->connecting_result, &c->connected); + grpc_connector_connect(c->connector, &args, &c->connecting_result, + &c->connected); } void grpc_subchannel_create_call(grpc_subchannel *c, @@ -275,78 +275,82 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, grpc_iomgr_closure *notify) { int do_connect = 0; gpr_mu_lock(&c->mu); - if (grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state, notify)) { - do_connect = 1; + if (grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state, + notify)) { + do_connect = 1; c->connecting = 1; subchannel_ref_locked(c); - grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); + grpc_connectivity_state_set(&c->state_tracker, + compute_connectivity_locked(c)); } gpr_mu_unlock(&c->mu); if (do_connect) { - start_connect(c); + start_connect(c); } } -void grpc_subchannel_process_transport_op(grpc_subchannel *c, grpc_transport_op *op) { - abort(); +void grpc_subchannel_process_transport_op(grpc_subchannel *c, + grpc_transport_op *op) { + abort(); } static void publish_transport(grpc_subchannel *c) { - size_t channel_stack_size; - connection *con; - grpc_channel_stack *stk; - size_t num_filters; - const grpc_channel_filter **filters; - waiting_for_connect *w4c; - int destroy; - - num_filters = c->num_filters + c->connecting_result.num_filters + 1; - filters = gpr_malloc(sizeof(*filters) * num_filters); - memcpy(filters, c->filters, sizeof(*filters) * c->num_filters); - memcpy(filters + c->num_filters, c->connecting_result.filters, sizeof(*filters) * c->connecting_result.num_filters); - filters[num_filters - 1] = &grpc_connected_channel_filter; - - channel_stack_size = grpc_channel_stack_size(filters, num_filters); - con = gpr_malloc(sizeof(connection) + channel_stack_size); - stk = (grpc_channel_stack *)(con + 1); - - con->refs = 0; - con->subchannel = c; - grpc_channel_stack_init(filters, num_filters, c->args, c->mdctx, stk); - grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); - memset(&c->connecting_result, 0, sizeof(c->connecting_result)); - - gpr_mu_lock(&c->mu); - GPR_ASSERT(c->active == NULL); - c->active = con; - c->connecting = 0; - connectivity_state_changed_locked(c); - while ((w4c = c->waiting)) { - abort(); /* not implemented */ - } + size_t channel_stack_size; + connection *con; + grpc_channel_stack *stk; + size_t num_filters; + const grpc_channel_filter **filters; + waiting_for_connect *w4c; + int destroy; + + num_filters = c->num_filters + c->connecting_result.num_filters + 1; + filters = gpr_malloc(sizeof(*filters) * num_filters); + memcpy(filters, c->filters, sizeof(*filters) * c->num_filters); + memcpy(filters + c->num_filters, c->connecting_result.filters, + sizeof(*filters) * c->connecting_result.num_filters); + filters[num_filters - 1] = &grpc_connected_channel_filter; + + channel_stack_size = grpc_channel_stack_size(filters, num_filters); + con = gpr_malloc(sizeof(connection) + channel_stack_size); + stk = (grpc_channel_stack *)(con + 1); + + con->refs = 0; + con->subchannel = c; + grpc_channel_stack_init(filters, num_filters, c->args, c->mdctx, stk); + grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); + memset(&c->connecting_result, 0, sizeof(c->connecting_result)); + + gpr_mu_lock(&c->mu); + GPR_ASSERT(c->active == NULL); + c->active = con; + c->connecting = 0; + connectivity_state_changed_locked(c); + while ((w4c = c->waiting)) { + abort(); /* not implemented */ + } destroy = subchannel_unref_locked(c); - gpr_mu_unlock(&c->mu); + gpr_mu_unlock(&c->mu); - gpr_free(filters); + gpr_free(filters); - if (destroy) { - subchannel_destroy(c); - } -} + if (destroy) { + subchannel_destroy(c); + } +} static void subchannel_connected(void *arg, int iomgr_success) { - grpc_subchannel *c = arg; - if (c->connecting_result.transport) { - publish_transport(c); - } else { - int destroy; - gpr_mu_lock(&c->mu); - destroy = subchannel_unref_locked(c); - gpr_mu_unlock(&c->mu); - if (destroy) subchannel_destroy(c); - /* TODO(ctiller): retry after sleeping */ - abort(); - } + grpc_subchannel *c = arg; + if (c->connecting_result.transport) { + publish_transport(c); + } else { + int destroy; + gpr_mu_lock(&c->mu); + destroy = subchannel_unref_locked(c); + gpr_mu_unlock(&c->mu); + if (destroy) subchannel_destroy(c); + /* TODO(ctiller): retry after sleeping */ + abort(); + } } static gpr_timespec compute_connect_deadline(grpc_subchannel *c) { @@ -372,21 +376,19 @@ static void connectivity_state_changed_locked(grpc_subchannel *c) { * grpc_subchannel_call implementation */ -void grpc_subchannel_call_ref(grpc_subchannel_call *c) { - gpr_ref(&c->refs); -} +void grpc_subchannel_call_ref(grpc_subchannel_call *c) { gpr_ref(&c->refs); } void grpc_subchannel_call_unref(grpc_subchannel_call *c) { if (gpr_unref(&c->refs)) { - gpr_mu *mu = &c->connection->subchannel->mu; - grpc_subchannel *destroy; + gpr_mu *mu = &c->connection->subchannel->mu; + grpc_subchannel *destroy; grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(c)); gpr_mu_lock(mu); destroy = connection_unref_locked(c->connection); gpr_mu_unlock(mu); gpr_free(c); if (destroy) { - subchannel_destroy(destroy); + subchannel_destroy(destroy); } } } @@ -398,9 +400,11 @@ void grpc_subchannel_call_process_op(grpc_subchannel_call *call, top_elem->filter->start_transport_stream_op(top_elem, op); } -grpc_subchannel_call *create_call(connection *con, grpc_transport_stream_op *initial_op) { - grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con); - grpc_subchannel_call *call = gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size); +grpc_subchannel_call *create_call(connection *con, + grpc_transport_stream_op *initial_op) { + grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con); + grpc_subchannel_call *call = + gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size); grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(call); call->connection = con; gpr_ref_init(&call->refs, 1); diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 8155aba14cc..b777e51d201 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -55,7 +55,8 @@ void grpc_subchannel_create_call(grpc_subchannel *subchannel, grpc_iomgr_closure *notify); /** process a transport level op */ -void grpc_subchannel_process_transport_op(grpc_subchannel *subchannel, grpc_transport_op *op); +void grpc_subchannel_process_transport_op(grpc_subchannel *subchannel, + grpc_transport_op *op); /** poll the current connectivity state of a channel */ grpc_connectivity_state grpc_subchannel_check_connectivity( @@ -67,8 +68,10 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *channel, grpc_connectivity_state *state, grpc_iomgr_closure *notify); -void grpc_subchannel_add_interested_party(grpc_subchannel *channel, grpc_pollset *pollset); -void grpc_subchannel_del_interested_party(grpc_subchannel *channel, grpc_pollset *pollset); +void grpc_subchannel_add_interested_party(grpc_subchannel *channel, + grpc_pollset *pollset); +void grpc_subchannel_del_interested_party(grpc_subchannel *channel, + grpc_pollset *pollset); /** continue processing a transport op */ void grpc_subchannel_call_process_op(grpc_subchannel_call *subchannel_call, From df91ba52d0ebbe98ce84508701283b82b2c0441b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 10:55:46 -0700 Subject: [PATCH 055/124] Add ability to continue waiting calls --- src/core/client_config/subchannel.c | 134 +++++++++++++++++++++++++--- 1 file changed, 124 insertions(+), 10 deletions(-) diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index c770cb3b20f..7bd6717a3da 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -49,11 +49,20 @@ typedef struct { grpc_subchannel *subchannel; } connection; +typedef struct { + grpc_iomgr_closure closure; + size_t version; + grpc_subchannel *subchannel; + grpc_connectivity_state connectivity_state; +} state_watcher; + typedef struct waiting_for_connect { struct waiting_for_connect *next; grpc_iomgr_closure *notify; - grpc_transport_stream_op *initial_op; + grpc_transport_stream_op initial_op; grpc_subchannel_call **target; + grpc_subchannel *subchannel; + grpc_iomgr_closure continuation; } waiting_for_connect; struct grpc_subchannel { @@ -85,6 +94,8 @@ struct grpc_subchannel { /** active connection */ connection *active; + /** version number for the active connection */ + size_t active_version; /** refcount */ int refs; /** are we connecting */ @@ -228,6 +239,16 @@ static void start_connect(grpc_subchannel *c) { &c->connected); } +static void continue_creating_call(void *arg, int iomgr_success) { + waiting_for_connect *w4c = arg; + grpc_subchannel_create_call(w4c->subchannel, + &w4c->initial_op, + w4c->target, + w4c->notify); + grpc_subchannel_unref(w4c->subchannel); + gpr_free(w4c); +} + void grpc_subchannel_create_call(grpc_subchannel *c, grpc_transport_stream_op *initial_op, grpc_subchannel_call **target, @@ -245,8 +266,11 @@ void grpc_subchannel_create_call(grpc_subchannel *c, waiting_for_connect *w4c = gpr_malloc(sizeof(*w4c)); w4c->next = c->waiting; w4c->notify = notify; - w4c->initial_op = initial_op; + w4c->initial_op = *initial_op; w4c->target = target; + w4c->subchannel = c; + subchannel_ref_locked(c); + grpc_iomgr_closure_init(&w4c->continuation, continue_creating_call, w4c); c->waiting = w4c; grpc_subchannel_add_interested_party(c, initial_op->bind_pollset); if (!c->connecting) { @@ -291,7 +315,70 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, void grpc_subchannel_process_transport_op(grpc_subchannel *c, grpc_transport_op *op) { - abort(); + abort(); /* not implemented */ +} + +static void on_state_changed(void *p, int iomgr_success) { + state_watcher *sw = p; + grpc_subchannel *c = sw->subchannel; + gpr_mu *mu = &c->mu; + int destroy; + grpc_transport_op op; + grpc_channel_element *elem; + connection *destroy_connection = NULL; + int do_connect = 0; + + gpr_mu_lock(mu); + + /* if we failed or there is a version number mismatch, just leave + this closure */ + if (!iomgr_success || sw->subchannel->active_version != sw->version) { + goto done; + } + + switch (sw->connectivity_state) { + case GRPC_CHANNEL_CONNECTING: + case GRPC_CHANNEL_READY: + case GRPC_CHANNEL_IDLE: + /* all is still good: keep watching */ + memset(&op, 0, sizeof(op)); + op.connectivity_state = &sw->connectivity_state; + op.on_connectivity_state_change = &sw->closure; + elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(c->active), 0); + elem->filter->start_transport_op(elem, &op); + /* early out */ + gpr_mu_unlock(mu); + return; + case GRPC_CHANNEL_FATAL_FAILURE: + /* things have gone wrong, deactivate and enter idle */ + if (sw->subchannel->active->refs == 0) { + destroy_connection = sw->subchannel->active; + } + sw->subchannel->active = NULL; + break; + case GRPC_CHANNEL_TRANSIENT_FAILURE: + /* things are starting to go wrong, reconnect but don't deactivate */ + subchannel_ref_locked(c); + do_connect = 1; + c->connecting = 1; + break; + } + +done: + grpc_connectivity_state_set(&c->state_tracker, + compute_connectivity_locked(c)); + destroy = subchannel_unref_locked(c); + gpr_free(sw); + gpr_mu_unlock(mu); + if (do_connect) { + start_connect(c); + } + if (destroy) { + subchannel_destroy(c); + } + if (destroy_connection != NULL) { + connection_destroy(destroy_connection); + } } static void publish_transport(grpc_subchannel *c) { @@ -301,8 +388,12 @@ static void publish_transport(grpc_subchannel *c) { size_t num_filters; const grpc_channel_filter **filters; waiting_for_connect *w4c; - int destroy; + grpc_transport_op op; + state_watcher *sw; + connection *destroy_connection = NULL; + grpc_channel_element *elem; + /* build final filter list */ num_filters = c->num_filters + c->connecting_result.num_filters + 1; filters = gpr_malloc(sizeof(*filters) * num_filters); memcpy(filters, c->filters, sizeof(*filters) * c->num_filters); @@ -310,31 +401,54 @@ static void publish_transport(grpc_subchannel *c) { sizeof(*filters) * c->connecting_result.num_filters); filters[num_filters - 1] = &grpc_connected_channel_filter; + /* construct channel stack */ channel_stack_size = grpc_channel_stack_size(filters, num_filters); con = gpr_malloc(sizeof(connection) + channel_stack_size); stk = (grpc_channel_stack *)(con + 1); - con->refs = 0; con->subchannel = c; grpc_channel_stack_init(filters, num_filters, c->args, c->mdctx, stk); grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); memset(&c->connecting_result, 0, sizeof(c->connecting_result)); + /* initialize state watcher */ + sw = gpr_malloc(sizeof(*sw)); + grpc_iomgr_closure_init(&sw->closure, on_state_changed, sw); + sw->subchannel = c; + sw->connectivity_state = GRPC_CHANNEL_READY; + gpr_mu_lock(&c->mu); - GPR_ASSERT(c->active == NULL); + + /* publish */ + if (c->active != NULL && c->active->refs == 0) { + destroy_connection = c->active; + } c->active = con; + c->active_version++; + sw->version = c->active_version; c->connecting = 0; + + /* watch for changes; subchannel ref for connecting is donated + to the state watcher */ + memset(&op, 0, sizeof(op)); + op.connectivity_state = &sw->connectivity_state; + op.on_connectivity_state_change = &sw->closure; + elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(c->active), 0); + elem->filter->start_transport_op(elem, &op); + + /* signal completion */ connectivity_state_changed_locked(c); while ((w4c = c->waiting)) { - abort(); /* not implemented */ + c->waiting = w4c->next; + grpc_iomgr_add_callback(&w4c->continuation); } - destroy = subchannel_unref_locked(c); + gpr_mu_unlock(&c->mu); gpr_free(filters); - if (destroy) { - subchannel_destroy(c); + if (destroy_connection != NULL) { + connection_destroy(destroy_connection); } } From f62d6fce9def07c392cbb462fcdc0cc618379957 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 10:55:59 -0700 Subject: [PATCH 056/124] .clang-format --- src/core/client_config/subchannel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 7bd6717a3da..a0d21d99ebc 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -241,10 +241,8 @@ static void start_connect(grpc_subchannel *c) { static void continue_creating_call(void *arg, int iomgr_success) { waiting_for_connect *w4c = arg; - grpc_subchannel_create_call(w4c->subchannel, - &w4c->initial_op, - w4c->target, - w4c->notify); + grpc_subchannel_create_call(w4c->subchannel, &w4c->initial_op, w4c->target, + w4c->notify); grpc_subchannel_unref(w4c->subchannel); gpr_free(w4c); } @@ -344,7 +342,8 @@ static void on_state_changed(void *p, int iomgr_success) { memset(&op, 0, sizeof(op)); op.connectivity_state = &sw->connectivity_state; op.on_connectivity_state_change = &sw->closure; - elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(c->active), 0); + elem = grpc_channel_stack_element( + CHANNEL_STACK_FROM_CONNECTION(c->active), 0); elem->filter->start_transport_op(elem, &op); /* early out */ gpr_mu_unlock(mu); @@ -433,7 +432,8 @@ static void publish_transport(grpc_subchannel *c) { memset(&op, 0, sizeof(op)); op.connectivity_state = &sw->connectivity_state; op.on_connectivity_state_change = &sw->closure; - elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(c->active), 0); + elem = + grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(c->active), 0); elem->filter->start_transport_op(elem, &op); /* signal completion */ From 268e59063a719856eec942c7eace029f34ca8432 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 29 Jun 2015 12:20:43 -0700 Subject: [PATCH 057/124] Adding required changes --- test/cpp/qps/perf_db.proto | 65 +++------------------- test/cpp/qps/perf_db_client.cc | 98 +++++++++++++++++++++------------- test/cpp/qps/perf_db_client.h | 48 +++++++++-------- test/cpp/qps/report.cc | 72 ++++++++++++------------- test/cpp/qps/report.h | 16 ++++-- 5 files changed, 138 insertions(+), 161 deletions(-) diff --git a/test/cpp/qps/perf_db.proto b/test/cpp/qps/perf_db.proto index 7f4a460812f..7a550f83c65 100644 --- a/test/cpp/qps/perf_db.proto +++ b/test/cpp/qps/perf_db.proto @@ -35,14 +35,12 @@ package grpc.testing; service PerfDbTransfer { // Sends client info - rpc RecordSingleClientData (SingleUserRecordRequest) returns (SingleUserRecordReply) {} - - rpc RetrieveSingleUserData (SingleUserRetrieveRequest) returns (SingleUserRetrieveReply) {} - - rpc RetrieveAllUsersData (AllUsersRetrieveRequest) returns (AllUsersRetrieveReply) {} + rpc RecordSingleClientData(SingleUserRecordRequest) + returns (SingleUserRecordReply) { + } } -//Metrics to be stored +// Metrics to be stored message Metrics { double qps = 1; double qps_per_core = 2; @@ -57,39 +55,7 @@ message Metrics { double client_user_time = 11; } -//Timestamped details -message DataDetails { - string timestamp = 1; - string test_name = 2; - string sys_info = 3; - string tag = 4; - Metrics metrics = 5; - ClientConfig client_config = 6; - ServerConfig server_config = 7; -} - -//User details -message UserDetails { - string id = 1; - string email = 2; - bool verified_email = 3; - string name = 4; - string given_name = 5; - string family_name = 6; - string link = 7; - string picture = 8; - string gender = 9; - string locale = 10; - string hd = 11; -} - -//Stored to database -message SingleUserDetails { - repeated DataDetails data_details = 1; - UserDetails user_details = 2; -} - -//Request for storing a single user's data +// Request for storing a single user's data message SingleUserRecordRequest { string access_token = 1; string test_name = 2; @@ -100,25 +66,6 @@ message SingleUserRecordRequest { ServerConfig server_config = 7; } -//Reply to request for storing single user's data +// Reply to request for storing single user's data message SingleUserRecordReply { } - -//Request for retrieving single user's data -message SingleUserRetrieveRequest { - string user_id = 1; -} - -//Reply for request to retrieve single user's data -message SingleUserRetrieveReply { - SingleUserDetails details = 1; -} - -//Request for retrieving all users' data -message AllUsersRetrieveReply { - repeated SingleUserDetails user_data = 1; -} - -//Reply to request for retrieving all users' data -message AllUsersRetrieveRequest { -} diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 65569e50778..c4ee0ae5b8d 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -36,25 +36,27 @@ namespace grpc { namespace testing { -//sets the client and server config information -void PerfDbClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) { +// sets the client and server config information +void PerfDbClient::setConfigs(const ClientConfig& clientConfig, + const ServerConfig& serverConfig) { this->clientConfig_ = clientConfig; this->serverConfig_ = serverConfig; } -//sets the QPS -void PerfDbClient::setQPS(double QPS) { - this->QPS_ = QPS; -} +// sets the QPS +void PerfDbClient::setQPS(double QPS) { this->QPS_ = QPS; } -//sets the QPS per core +// sets the QPS per core void PerfDbClient::setQPSPerCore(double QPSPerCore) { this->QPSPerCore_ = QPSPerCore; } -//sets the 50th, 90th, 95th, 99th and 99.9th percentile latency -void PerfDbClient::setLatencies(double percentileLatency50, double percentileLatency90, - double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) { +// sets the 50th, 90th, 95th, 99th and 99.9th percentile latency +void PerfDbClient::setLatencies(double percentileLatency50, + double percentileLatency90, + double percentileLatency95, + double percentileLatency99, + double percentileLatency99Point9) { this->percentileLatency50_ = percentileLatency50; this->percentileLatency90_ = percentileLatency90; this->percentileLatency95_ = percentileLatency95; @@ -62,54 +64,78 @@ void PerfDbClient::setLatencies(double percentileLatency50, double percentileLat this->percentileLatency99Point9_ = percentileLatency99Point9; } -//sets the server and client, user and system times -void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, - double clientSystemTime, double clientUserTime) { +// sets the server and client, user and system times +void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, + double clientSystemTime, double clientUserTime) { this->serverSystemTime_ = serverSystemTime; this->serverUserTime_ = serverUserTime; this->clientSystemTime_ = clientSystemTime; this->clientUserTime_ = clientUserTime; } -//sends the data to the performancew database server -int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag) { - //Data record request object +// sends the data to the performance database server +bool PerfDbClient::sendData(std::string access_token, std::string test_name, + std::string sys_info, std::string tag) { + // Data record request object SingleUserRecordRequest singleUserRecordRequest; - //setting access token, name of the test and the system information + // setting access token, name of the test and the system information singleUserRecordRequest.set_access_token(access_token); singleUserRecordRequest.set_test_name(test_name); singleUserRecordRequest.set_sys_info(sys_info); singleUserRecordRequest.set_tag(tag); - //setting configs + // setting configs *(singleUserRecordRequest.mutable_client_config()) = this->clientConfig_; *(singleUserRecordRequest.mutable_server_config()) = this->serverConfig_; - + Metrics* metrics = singleUserRecordRequest.mutable_metrics(); - //setting metrcs in data record request - if(QPS_ != DBL_MIN) metrics->set_qps(this->QPS_); - if(QPSPerCore_ != DBL_MIN) metrics->set_qps_per_core(this->QPSPerCore_); - if(percentileLatency50_ != DBL_MIN) metrics->set_perc_lat_50(this->percentileLatency50_); - if(percentileLatency90_ != DBL_MIN) metrics->set_perc_lat_90(this->percentileLatency90_); - if(percentileLatency95_ != DBL_MIN) metrics->set_perc_lat_95(this->percentileLatency95_); - if(percentileLatency99_ != DBL_MIN) metrics->set_perc_lat_99(this->percentileLatency99_); - if(percentileLatency99Point9_ != DBL_MIN) metrics->set_perc_lat_99_point_9(this->percentileLatency99Point9_); - if(serverSystemTime_ != DBL_MIN) metrics->set_server_system_time(this->serverSystemTime_); - if(serverUserTime_ != DBL_MIN) metrics->set_server_user_time(this->serverUserTime_); - if(clientSystemTime_ != DBL_MIN) metrics->set_client_system_time(this->clientSystemTime_); - if(clientUserTime_ != DBL_MIN) metrics->set_client_user_time(this->clientUserTime_); + // setting metrcs in data record request + if (QPS_ != DBL_MIN) { + metrics->set_qps(this->QPS_); + } + if (QPSPerCore_ != DBL_MIN) { + metrics->set_qps_per_core(this->QPSPerCore_); + } + if (percentileLatency50_ != DBL_MIN) { + metrics->set_perc_lat_50(this->percentileLatency50_); + } + if (percentileLatency90_ != DBL_MIN) { + metrics->set_perc_lat_90(this->percentileLatency90_); + } + if (percentileLatency95_ != DBL_MIN) { + metrics->set_perc_lat_95(this->percentileLatency95_); + } + if (percentileLatency99_ != DBL_MIN) { + metrics->set_perc_lat_99(this->percentileLatency99_); + } + if (percentileLatency99Point9_ != DBL_MIN) { + metrics->set_perc_lat_99_point_9(this->percentileLatency99Point9_); + } + if (serverSystemTime_ != DBL_MIN) { + metrics->set_server_system_time(this->serverSystemTime_); + } + if (serverUserTime_ != DBL_MIN) { + metrics->set_server_user_time(this->serverUserTime_); + } + if (clientSystemTime_ != DBL_MIN) { + metrics->set_client_system_time(this->clientSystemTime_); + } + if (clientUserTime_ != DBL_MIN) { + metrics->set_client_user_time(this->clientUserTime_); + } SingleUserRecordReply singleUserRecordReply; ClientContext context; - Status status = stub_->RecordSingleClientData(&context, singleUserRecordRequest, &singleUserRecordReply); + Status status = stub_->RecordSingleClientData( + &context, singleUserRecordRequest, &singleUserRecordReply); if (status.ok()) { - return 1; //data sent to database successfully + return true; // data sent to database successfully } else { - return -1; //error in data sending + return false; // error in data sending } } -} //testing -} //grpc +} // testing +} // grpc diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index be4766ab055..b1ba98831cc 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -45,13 +45,12 @@ #include #include "test/cpp/qps/perf_db.grpc.pb.h" - -namespace grpc{ +namespace grpc { namespace testing { -//Manages data sending to performance database server +// Manages data sending to performance database server class PerfDbClient { -public: + public: PerfDbClient() { QPS_ = DBL_MIN; QPSPerCore_ = DBL_MIN; @@ -65,32 +64,37 @@ public: clientSystemTime_ = DBL_MIN; clientUserTime_ = DBL_MIN; } - - void init(std::shared_ptr channel) { stub_ = PerfDbTransfer::NewStub(channel); } + + void init(std::shared_ptr channel) { + stub_ = PerfDbTransfer::NewStub(channel); + } ~PerfDbClient() {} - //sets the client and server config information - void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig); - - //sets the QPS + // sets the client and server config information + void setConfigs(const ClientConfig& clientConfig, + const ServerConfig& serverConfig); + + // sets the QPS void setQPS(double QPS); - //sets the QPS per core + // sets the QPS per core void setQPSPerCore(double QPSPerCore); - //sets the 50th, 90th, 95th, 99th and 99.9th percentile latency + // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency void setLatencies(double percentileLatency50, double percentileLatency90, - double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); + double percentileLatency95, double percentileLatency99, + double percentileLatency99Point9); - //sets the server and client, user and system times - void setTimes(double serverSystemTime, double serverUserTime, - double clientSystemTime, double clientUserTime); + // sets the server and client, user and system times + void setTimes(double serverSystemTime, double serverUserTime, + double clientSystemTime, double clientUserTime); - //sends the data to the performancew database server - int sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag); + // sends the data to the performance database server + bool sendData(std::string access_token, std::string test_name, + std::string sys_info, std::string tag); -private: + private: std::unique_ptr stub_; ClientConfig clientConfig_; ServerConfig serverConfig_; @@ -107,7 +111,5 @@ private: double clientUserTime_; }; -} //namespace testing -} //namespace grpc - - +} // namespace testing +} // namespace grpc diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 7167d4e336a..d8041adca40 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -67,7 +67,6 @@ void CompositeReporter::ReportTimes(const ScenarioResult& result) { } } - void GprLogReporter::ReportQPS(const ScenarioResult& result) { gpr_log(GPR_INFO, "QPS: %.1f", result.latencies.Count() / @@ -76,10 +75,9 @@ void GprLogReporter::ReportQPS(const ScenarioResult& result) { } void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) { - auto qps = - result.latencies.Count() / - average(result.client_resources, - [](ResourceUsage u) { return u.wall_time; }); + auto qps = result.latencies.Count() / + average(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps, qps / result.server_config.threads()); @@ -120,8 +118,8 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) { void PerfDbReporter::ReportQPS(const ScenarioResult& result) { auto qps = result.latencies.Count() / - average(result.client_resources, - [](ResourceUsage u) { return u.wall_time; }); + average(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); perfDbClient_.setQPS(qps); perfDbClient_.setConfigs(result.client_config, result.server_config); @@ -129,8 +127,8 @@ void PerfDbReporter::ReportQPS(const ScenarioResult& result) { void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) { auto qps = result.latencies.Count() / - average(result.client_resources, - [](ResourceUsage u) { return u.wall_time; }); + average(result.client_resources, + [](ResourceUsage u) { return u.wall_time; }); auto qpsPerCore = qps / result.server_config.threads(); @@ -141,48 +139,46 @@ void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) { void PerfDbReporter::ReportLatency(const ScenarioResult& result) { perfDbClient_.setLatencies(result.latencies.Percentile(50) / 1000, - result.latencies.Percentile(90) / 1000, - result.latencies.Percentile(95) / 1000, - result.latencies.Percentile(99) / 1000, - result.latencies.Percentile(99.9) / 1000); + result.latencies.Percentile(90) / 1000, + result.latencies.Percentile(95) / 1000, + result.latencies.Percentile(99) / 1000, + result.latencies.Percentile(99.9) / 1000); perfDbClient_.setConfigs(result.client_config, result.server_config); } void PerfDbReporter::ReportTimes(const ScenarioResult& result) { - double serverSystemTime = 100.0 * sum(result.server_resources, + double serverSystemTime = + 100.0 * sum(result.server_resources, [](ResourceUsage u) { return u.system_time; }) / - sum(result.server_resources, - [](ResourceUsage u) { return u.wall_time; }); - double serverUserTime = 100.0 * sum(result.server_resources, + sum(result.server_resources, [](ResourceUsage u) { return u.wall_time; }); + double serverUserTime = + 100.0 * sum(result.server_resources, [](ResourceUsage u) { return u.user_time; }) / - sum(result.server_resources, - [](ResourceUsage u) { return u.wall_time; }); - double clientSystemTime = 100.0 * sum(result.client_resources, + sum(result.server_resources, [](ResourceUsage u) { return u.wall_time; }); + double clientSystemTime = + 100.0 * sum(result.client_resources, [](ResourceUsage u) { return u.system_time; }) / - sum(result.client_resources, - [](ResourceUsage u) { return u.wall_time; }); - double clientUserTime = 100.0 * sum(result.client_resources, + sum(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); + double clientUserTime = + 100.0 * sum(result.client_resources, [](ResourceUsage u) { return u.user_time; }) / - sum(result.client_resources, - [](ResourceUsage u) { return u.wall_time; }); + sum(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - perfDbClient_.setTimes(serverSystemTime, serverUserTime, - clientSystemTime, clientUserTime); + perfDbClient_.setTimes(serverSystemTime, serverUserTime, clientSystemTime, + clientUserTime); perfDbClient_.setConfigs(result.client_config, result.server_config); } void PerfDbReporter::SendData() { - //send data to performance database - int dataState = perfDbClient_.sendData(access_token_, test_name_, sys_info_, tag_); - - //check state of data sending - switch(dataState) { - case 1: - gpr_log(GPR_INFO, "Data sent to performance database successfully"); - break; - case -1: - gpr_log(GPR_INFO, "Data could not be sent to performance database"); - break; + // send data to performance database + bool dataState = + perfDbClient_.sendData(access_token_, test_name_, sys_info_, tag_); + + // check state of data sending + if (dataState) { + gpr_log(GPR_INFO, "Data sent to performance database successfully"); + } else { + gpr_log(GPR_INFO, "Data could not be sent to performance database"); } } diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 565590649ab..330d4ebd295 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -107,12 +107,18 @@ class GprLogReporter : public Reporter { /** Reporter for performance database tool */ class PerfDbReporter : public Reporter { public: - PerfDbReporter(const string& name, const string& access_token, const string& test_name, - const string& sys_info, const string& server_address, const string& tag) - : Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info), tag_(tag) { - perfDbClient_.init(grpc::CreateChannel(server_address, grpc::InsecureCredentials(), ChannelArguments())); + PerfDbReporter(const string& name, const string& access_token, + const string& test_name, const string& sys_info, + const string& server_address, const string& tag) + : Reporter(name), + access_token_(access_token), + test_name_(test_name), + sys_info_(sys_info), + tag_(tag) { + perfDbClient_.init(grpc::CreateChannel( + server_address, grpc::InsecureCredentials(), ChannelArguments())); } - ~PerfDbReporter() { SendData(); }; + ~PerfDbReporter() GRPC_OVERRIDE { SendData(); }; private: PerfDbClient perfDbClient_; From 25481f72c1d519136b7fdd13f906f6ecaa9ee268 Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 29 Jun 2015 13:27:23 -0700 Subject: [PATCH 058/124] Resolving merge conflict --- Makefile | 71 +----------------------- build.json | 15 ----- tools/run_tests/sources_and_headers.json | 3 + 3 files changed, 5 insertions(+), 84 deletions(-) diff --git a/Makefile b/Makefile index b1da79ea4c8..195793342c6 100644 --- a/Makefile +++ b/Makefile @@ -3557,63 +3557,6 @@ endif endif -<<<<<<< HEAD -LIBGRPC++_BENCHMARK_CONFIG_SRC = \ - $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc \ - $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc \ - test/cpp/qps/perf_db_client.cc \ - test/cpp/qps/report.cc \ - test/cpp/util/benchmark_config.cc \ - - -LIBGRPC++_BENCHMARK_CONFIG_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_BENCHMARK_CONFIG_SRC)))) - -ifeq ($(NO_SECURE),true) - -# You can't build secure libraries if you don't have OpenSSL with ALPN. - -$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: openssl_dep_error - - -else - -ifeq ($(NO_PROTOBUF),true) - -# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. - -$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: protobuf_dep_error - - -else - -$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_BENCHMARK_CONFIG_OBJS) - $(E) "[AR] Creating $@" - $(Q) mkdir -p `dirname $@` - $(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a - $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBGRPC++_BENCHMARK_CONFIG_OBJS) -ifeq ($(SYSTEM),Darwin) - $(Q) ranlib $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a -endif - - - - -endif - -endif - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(LIBGRPC++_BENCHMARK_CONFIG_OBJS:.o=.dep) -endif -endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/perf_db_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc - - -======= ->>>>>>> a6de02f5ef15646c12f495f11c410326d34e5dfe LIBGRPC++_TEST_CONFIG_SRC = \ test/cpp/util/test_config.cc \ @@ -4180,26 +4123,16 @@ ifneq ($(NO_DEPS),true) -include $(LIBQPS_OBJS:.o=.dep) endif endif -<<<<<<< HEAD $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/perf_db_client.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc -======= -$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc ->>>>>>> a6de02f5ef15646c12f495f11c410326d34e5dfe +$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(GENDIR)/test/cpp/qps/perf_db.pb.cc $(GENDIR)/test/cpp/qps/perf_db.grpc.pb.cc LIBGRPC_CSHARP_EXT_SRC = \ diff --git a/build.json b/build.json index 39f6158d0c6..7e37bc4e29d 100644 --- a/build.json +++ b/build.json @@ -556,21 +556,6 @@ "vs_project_guid": "{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}" }, { -<<<<<<< HEAD - "name": "grpc++_benchmark_config", - "build": "private", - "language": "c++", - "src": [ - "test/cpp/qps/qpstest.proto", - "test/cpp/qps/perf_db.proto", - "test/cpp/qps/perf_db_client.cc", - "test/cpp/qps/report.cc", - "test/cpp/util/benchmark_config.cc" - ] - }, - { -======= ->>>>>>> a6de02f5ef15646c12f495f11c410326d34e5dfe "name": "grpc++_test_config", "build": "private", "language": "c++", diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index eb2514fa46d..13d77d571bf 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -9779,6 +9779,8 @@ "test/cpp/qps/driver.h", "test/cpp/qps/histogram.h", "test/cpp/qps/interarrival.h", + "test/cpp/qps/perf_db.grpc.pb.h", + "test/cpp/qps/perf_db.pb.h", "test/cpp/qps/qps_worker.h", "test/cpp/qps/qpstest.grpc.pb.h", "test/cpp/qps/qpstest.pb.h", @@ -9798,6 +9800,7 @@ "test/cpp/qps/driver.h", "test/cpp/qps/histogram.h", "test/cpp/qps/interarrival.h", + "test/cpp/qps/perf_db_client.cc", "test/cpp/qps/qps_worker.cc", "test/cpp/qps/qps_worker.h", "test/cpp/qps/report.cc", From b713546e4daa47f9b6555e6d1db71c88dc1be1fd Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Mon, 29 Jun 2015 14:14:37 -0700 Subject: [PATCH 059/124] Resolving dependency error in Jenkins --- build.json | 1 + tools/run_tests/sources_and_headers.json | 2 ++ 2 files changed, 3 insertions(+) diff --git a/build.json b/build.json index 7e37bc4e29d..56c39045625 100644 --- a/build.json +++ b/build.json @@ -748,6 +748,7 @@ "test/cpp/qps/driver.h", "test/cpp/qps/histogram.h", "test/cpp/qps/interarrival.h", + "test/cpp/qps/perf_db_client.h", "test/cpp/qps/qps_worker.h", "test/cpp/qps/report.h", "test/cpp/qps/server.h", diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 13d77d571bf..675a2fb3b93 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -9781,6 +9781,7 @@ "test/cpp/qps/interarrival.h", "test/cpp/qps/perf_db.grpc.pb.h", "test/cpp/qps/perf_db.pb.h", + "test/cpp/qps/perf_db_client.h", "test/cpp/qps/qps_worker.h", "test/cpp/qps/qpstest.grpc.pb.h", "test/cpp/qps/qpstest.pb.h", @@ -9801,6 +9802,7 @@ "test/cpp/qps/histogram.h", "test/cpp/qps/interarrival.h", "test/cpp/qps/perf_db_client.cc", + "test/cpp/qps/perf_db_client.h", "test/cpp/qps/qps_worker.cc", "test/cpp/qps/qps_worker.h", "test/cpp/qps/report.cc", From 98465035671778ea65891a28bc2c01776a6418cc Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 14:36:42 -0700 Subject: [PATCH 060/124] Debugging --- src/core/channel/channel_stack.c | 4 +- src/core/channel/channel_stack.h | 3 +- src/core/channel/client_channel.c | 62 ++++++++++++++----- src/core/channel/connected_channel.c | 2 +- src/core/channel/http_client_filter.c | 2 +- src/core/channel/http_server_filter.c | 2 +- src/core/channel/noop_filter.c | 2 +- src/core/client_config/resolver.c | 26 +++++++- src/core/client_config/resolver.h | 25 ++++++-- .../client_config/resolvers/dns_resolver.c | 33 ++++------ .../resolvers/unix_resolver_posix.c | 23 ++----- src/core/client_config/subchannel.c | 13 +++- src/core/client_config/subchannel.h | 2 + src/core/iomgr/iomgr.c | 11 ++++ src/core/security/client_auth_filter.c | 2 +- src/core/security/server_auth_filter.c | 2 +- src/core/surface/channel.c | 12 +++- src/core/surface/channel_create.c | 4 +- src/core/surface/lame_client.c | 2 +- src/core/surface/server.c | 2 +- src/core/transport/connectivity_state.c | 4 ++ test/core/channel/channel_stack_test.c | 4 +- test/core/end2end/tests/request_with_flags.c | 7 ++- 23 files changed, 168 insertions(+), 81 deletions(-) diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c index ff1077ce4cb..0810a61cd0a 100644 --- a/src/core/channel/channel_stack.c +++ b/src/core/channel/channel_stack.c @@ -102,7 +102,7 @@ grpc_call_element *grpc_call_stack_element(grpc_call_stack *call_stack, } void grpc_channel_stack_init(const grpc_channel_filter **filters, - size_t filter_count, const grpc_channel_args *args, + size_t filter_count, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, grpc_channel_stack *stack) { size_t call_size = @@ -122,7 +122,7 @@ void grpc_channel_stack_init(const grpc_channel_filter **filters, for (i = 0; i < filter_count; i++) { elems[i].filter = filters[i]; elems[i].channel_data = user_data; - elems[i].filter->init_channel_elem(&elems[i], args, metadata_context, + elems[i].filter->init_channel_elem(&elems[i], master, args, metadata_context, i == 0, i == (filter_count - 1)); user_data += ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); call_size += ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_call_data); diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h index 5ac2372f3a6..6db98815df7 100644 --- a/src/core/channel/channel_stack.h +++ b/src/core/channel/channel_stack.h @@ -97,6 +97,7 @@ typedef struct { useful for asserting correct configuration by upper layer code. The filter does not need to do any chaining */ void (*init_channel_elem)(grpc_channel_element *elem, + grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last); @@ -151,7 +152,7 @@ size_t grpc_channel_stack_size(const grpc_channel_filter **filters, size_t filter_count); /* Initialize a channel stack given some filters */ void grpc_channel_stack_init(const grpc_channel_filter **filters, - size_t filter_count, const grpc_channel_args *args, + size_t filter_count, grpc_channel *master,const grpc_channel_args *args, grpc_mdctx *metadata_context, grpc_channel_stack *stack); /* Destroy a channel stack */ diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index e2f8debdfad..ee0d2cd9bda 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -38,6 +38,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/connected_channel.h" +#include "src/core/surface/channel.h" #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/pollset_set.h" #include "src/core/support/string.h" @@ -56,6 +57,8 @@ typedef struct { grpc_mdctx *mdctx; /** resolver for this channel */ grpc_resolver *resolver; + /** master channel */ + grpc_channel *master; /** mutex protecting client configuration, resolution state */ gpr_mu mu_config; @@ -321,10 +324,6 @@ static void cc_start_transport_stream_op(grpc_call_element *elem, perform_transport_stream_op(elem, op, 0); } -static void update_state_locked(channel_data *chand) { - gpr_log(GPR_ERROR, "update_state_locked not implemented"); -} - static void cc_on_config_changed(void *arg, int iomgr_success) { channel_data *chand = arg; grpc_lb_policy *lb_policy = NULL; @@ -350,31 +349,42 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { } gpr_mu_unlock(&chand->mu_config); - while (wakeup_closures) { - grpc_iomgr_closure *next = wakeup_closures->next; - grpc_iomgr_add_callback(wakeup_closures); - wakeup_closures = next; - } - if (old_lb_policy) { GRPC_LB_POLICY_UNREF(old_lb_policy, "channel"); } - if (iomgr_success) { + gpr_mu_lock(&chand->mu_config); + if (iomgr_success && chand->resolver) { + grpc_resolver *resolver = chand->resolver; + GRPC_RESOLVER_REF(resolver, "channel-next"); + gpr_mu_unlock(&chand->mu_config); + GRPC_CHANNEL_INTERNAL_REF(chand->master, "resolver"); grpc_resolver_next(chand->resolver, &chand->incoming_configuration, &chand->on_config_changed); + GRPC_RESOLVER_UNREF(resolver, "channel-next"); } else { - gpr_mu_lock(&chand->mu_config); old_resolver = chand->resolver; chand->resolver = NULL; - update_state_locked(chand); + grpc_connectivity_state_set(&chand->state_tracker, GRPC_CHANNEL_FATAL_FAILURE); gpr_mu_unlock(&chand->mu_config); - grpc_resolver_unref(old_resolver); + if (old_resolver != NULL) { + grpc_resolver_shutdown(old_resolver); + GRPC_RESOLVER_UNREF(old_resolver, "channel"); + } + } + + while (wakeup_closures) { + grpc_iomgr_closure *next = wakeup_closures->next; + grpc_iomgr_add_callback(wakeup_closures); + wakeup_closures = next; } + + GRPC_CHANNEL_INTERNAL_UNREF(chand->master, "resolver"); } static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op *op) { grpc_lb_policy *lb_policy = NULL; channel_data *chand = elem->channel_data; + grpc_resolver *destroy_resolver = NULL; grpc_iomgr_closure *on_consumed = op->on_consumed; op->on_consumed = NULL; @@ -388,6 +398,13 @@ static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op op->connectivity_state = NULL; } + if (op->disconnect && chand->resolver != NULL) { + grpc_connectivity_state_set(&chand->state_tracker, GRPC_CHANNEL_FATAL_FAILURE); + destroy_resolver = chand->resolver; + chand->resolver = NULL; + op->disconnect = 0; + } + if (!is_empty(op, sizeof(*op))) { lb_policy = chand->lb_policy; if (lb_policy) { @@ -396,6 +413,11 @@ static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op } gpr_mu_unlock(&chand->mu_config); + if (destroy_resolver) { + grpc_resolver_shutdown(destroy_resolver); + GRPC_RESOLVER_UNREF(destroy_resolver, "channel"); + } + if (lb_policy) { grpc_lb_policy_broadcast(lb_policy, op); GRPC_LB_POLICY_UNREF(lb_policy, "broadcast"); @@ -432,6 +454,7 @@ static void destroy_call_elem(grpc_call_element *elem) { remove it from the in-flight requests tracked by the child_entry we picked */ gpr_mu_lock(&calld->mu_state); + gpr_log(GPR_DEBUG, "call_elem destroy @ state %d", calld->state); switch (calld->state) { case CALL_ACTIVE: subchannel_call = calld->subchannel_call; @@ -452,7 +475,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { @@ -465,7 +488,10 @@ static void init_channel_elem(grpc_channel_element *elem, gpr_mu_init(&chand->mu_config); chand->mdctx = metadata_context; + chand->master = master; grpc_iomgr_closure_init(&chand->on_config_changed, cc_on_config_changed, chand); + + grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE); } /* Destructor for channel_data */ @@ -473,7 +499,8 @@ static void destroy_channel_elem(grpc_channel_element *elem) { channel_data *chand = elem->channel_data; if (chand->resolver != NULL) { - grpc_resolver_unref(chand->resolver); + grpc_resolver_shutdown(chand->resolver); + GRPC_RESOLVER_UNREF(chand->resolver, "channel"); } if (chand->lb_policy != NULL) { GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel"); @@ -494,6 +521,7 @@ void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, channel_data *chand = elem->channel_data; GPR_ASSERT(!chand->resolver); chand->resolver = resolver; - grpc_resolver_ref(resolver); + GRPC_CHANNEL_INTERNAL_REF(chand->master, "resolver"); + GRPC_RESOLVER_REF(resolver, "channel"); grpc_resolver_next(resolver, &chand->incoming_configuration, &chand->on_config_changed); } diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 84caecb6b35..99c8a643f62 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -103,7 +103,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { channel_data *cd = (channel_data *)elem->channel_data; diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index 5dec734c8cd..3d1fc6a0204 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -170,7 +170,7 @@ static const char *scheme_from_args(const grpc_channel_args *args) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { /* grab pointers to our data from the channel element */ diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c index dac53e9bf1a..3b1128bef9d 100644 --- a/src/core/channel/http_server_filter.c +++ b/src/core/channel/http_server_filter.c @@ -229,7 +229,7 @@ static void init_call_elem(grpc_call_element *elem, static void destroy_call_elem(grpc_call_element *elem) {} /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { /* grab pointers to our data from the channel element */ diff --git a/src/core/channel/noop_filter.c b/src/core/channel/noop_filter.c index 1478f04a3c2..0d9c2e82a82 100644 --- a/src/core/channel/noop_filter.c +++ b/src/core/channel/noop_filter.c @@ -95,7 +95,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { /* grab pointers to our data from the channel element */ diff --git a/src/core/client_config/resolver.c b/src/core/client_config/resolver.c index 11ba27e58d8..bbc0ec4e819 100644 --- a/src/core/client_config/resolver.c +++ b/src/core/client_config/resolver.c @@ -33,12 +33,34 @@ #include "src/core/client_config/resolver.h" +void grpc_resolver_init(grpc_resolver *resolver, + const grpc_resolver_vtable *vtable) { + resolver->vtable = vtable; + gpr_ref_init(&resolver->refs, 1); +} + +#ifdef GRPC_RESOLVER_REFCOUNT_DEBUG +void grpc_resolver_ref(grpc_resolver *resolver, const char *file, int line, + const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "RESOLVER:%p ref %d -> %d %s", + resolver, (int)resolver->refs.count, (int)resolver->refs.count + 1, reason); +#else void grpc_resolver_ref(grpc_resolver *resolver) { - resolver->vtable->ref(resolver); +#endif + gpr_ref(&resolver->refs); } +#ifdef GRPC_RESOLVER_REFCOUNT_DEBUG +void grpc_resolver_unref(grpc_resolver *resolver, const char *file, int line, + const char *reason) { + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "RESOLVER:%p unref %d -> %d %s", + resolver, (int)resolver->refs.count, (int)resolver->refs.count - 1, reason); +#else void grpc_resolver_unref(grpc_resolver *resolver) { - resolver->vtable->unref(resolver); +#endif + if (gpr_unref(&resolver->refs)) { + resolver->vtable->destroy(resolver); + } } void grpc_resolver_shutdown(grpc_resolver *resolver) { diff --git a/src/core/client_config/resolver.h b/src/core/client_config/resolver.h index 7776870c083..16b5964eb6e 100644 --- a/src/core/client_config/resolver.h +++ b/src/core/client_config/resolver.h @@ -45,11 +45,11 @@ typedef struct grpc_resolver_vtable grpc_resolver_vtable; objects */ struct grpc_resolver { const grpc_resolver_vtable *vtable; + gpr_refcount refs; }; struct grpc_resolver_vtable { - void (*ref)(grpc_resolver *resolver); - void (*unref)(grpc_resolver *resolver); + void (*destroy)(grpc_resolver *resolver); void (*shutdown)(grpc_resolver *resolver); void (*channel_saw_error)(grpc_resolver *resolver, struct sockaddr *failing_address, @@ -58,8 +58,25 @@ struct grpc_resolver_vtable { grpc_iomgr_closure *on_complete); }; -void grpc_resolver_ref(grpc_resolver *resolver); -void grpc_resolver_unref(grpc_resolver *resolver); +#ifdef GRPC_RESOLVER_REFCOUNT_DEBUG +#define GRPC_RESOLVER_REF(p, r) \ + grpc_resolver_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_RESOLVER_UNREF(p, r) \ + grpc_resolver_unref((p), __FILE__, __LINE__, (r)) +void grpc_resolver_ref(grpc_resolver *policy, const char *file, int line, + const char *reason); +void grpc_resolver_unref(grpc_resolver *policy, const char *file, int line, + const char *reason); +#else +#define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p)) +#define GRPC_RESOLVER_UNREF(p, r) grpc_resolver_unref((p)) +void grpc_resolver_ref(grpc_resolver *policy); +void grpc_resolver_unref(grpc_resolver *policy); +#endif + +void grpc_resolver_init(grpc_resolver *resolver, + const grpc_resolver_vtable *vtable); + void grpc_resolver_shutdown(grpc_resolver *resolver); /** Notification that the channel has seen an error on some address. diff --git a/src/core/client_config/resolvers/dns_resolver.c b/src/core/client_config/resolvers/dns_resolver.c index 8693bcf5eb4..c64491ae51b 100644 --- a/src/core/client_config/resolvers/dns_resolver.c +++ b/src/core/client_config/resolvers/dns_resolver.c @@ -73,13 +73,11 @@ typedef struct { grpc_client_config *resolved_config; } dns_resolver; -static void dns_destroy(dns_resolver *r); +static void dns_destroy(grpc_resolver *r); static void dns_start_resolving_locked(dns_resolver *r); static void dns_maybe_finish_next_locked(dns_resolver *r); -static void dns_ref(grpc_resolver *r); -static void dns_unref(grpc_resolver *r); static void dns_shutdown(grpc_resolver *r); static void dns_channel_saw_error(grpc_resolver *r, struct sockaddr *failing_address, @@ -88,26 +86,13 @@ static void dns_next(grpc_resolver *r, grpc_client_config **target_config, grpc_iomgr_closure *on_complete); static const grpc_resolver_vtable dns_resolver_vtable = { - dns_ref, dns_unref, dns_shutdown, dns_channel_saw_error, dns_next}; - -static void dns_ref(grpc_resolver *resolver) { - dns_resolver *r = (dns_resolver *)resolver; - gpr_ref(&r->refs); -} - -static void dns_unref(grpc_resolver *resolver) { - dns_resolver *r = (dns_resolver *)resolver; - if (gpr_unref(&r->refs)) { - dns_destroy(r); - } -} + dns_destroy, dns_shutdown, dns_channel_saw_error, dns_next}; static void dns_shutdown(grpc_resolver *resolver) { dns_resolver *r = (dns_resolver *)resolver; gpr_mu_lock(&r->mu); if (r->next_completion != NULL) { *r->target_config = NULL; - /* TODO(ctiller): add delayed callback */ grpc_iomgr_add_callback(r->next_completion); r->next_completion = NULL; } @@ -160,8 +145,12 @@ static void dns_on_resolved(void *arg, grpc_resolved_addresses *addresses) { lb_policy = r->lb_policy_factory(subchannels, addresses->naddrs); grpc_client_config_set_lb_policy(config, lb_policy); GRPC_LB_POLICY_UNREF(lb_policy, "construction"); + grpc_resolved_addresses_destroy(addresses); + gpr_free(subchannels); } gpr_mu_lock(&r->mu); + GPR_ASSERT(r->resolving); + r->resolving = 0; if (r->resolved_config) { grpc_client_config_unref(r->resolved_config); } @@ -170,11 +159,12 @@ static void dns_on_resolved(void *arg, grpc_resolved_addresses *addresses) { dns_maybe_finish_next_locked(r); gpr_mu_unlock(&r->mu); - dns_unref(&r->base); + GRPC_RESOLVER_UNREF(&r->base, "dns-resolving"); } static void dns_start_resolving_locked(dns_resolver *r) { - dns_ref(&r->base); + GRPC_RESOLVER_REF(&r->base, "dns-resolving"); + GPR_ASSERT(!r->resolving); r->resolving = 1; grpc_resolve_address(r->name, r->default_port, dns_on_resolved, r); } @@ -190,7 +180,8 @@ static void dns_maybe_finish_next_locked(dns_resolver *r) { } } -static void dns_destroy(dns_resolver *r) { +static void dns_destroy(grpc_resolver *gr) { + dns_resolver *r = (dns_resolver *)gr; gpr_mu_destroy(&r->mu); if (r->resolved_config) { grpc_client_config_unref(r->resolved_config); @@ -220,7 +211,7 @@ static grpc_resolver *dns_create( memset(r, 0, sizeof(*r)); gpr_ref_init(&r->refs, 1); gpr_mu_init(&r->mu); - r->base.vtable = &dns_resolver_vtable; + grpc_resolver_init(&r->base, &dns_resolver_vtable); r->name = gpr_strdup(path); r->default_port = gpr_strdup(default_port); r->subchannel_factory = subchannel_factory; diff --git a/src/core/client_config/resolvers/unix_resolver_posix.c b/src/core/client_config/resolvers/unix_resolver_posix.c index f7498548b11..7f2008685c7 100644 --- a/src/core/client_config/resolvers/unix_resolver_posix.c +++ b/src/core/client_config/resolvers/unix_resolver_posix.c @@ -71,12 +71,10 @@ typedef struct { grpc_client_config **target_config; } unix_resolver; -static void unix_destroy(unix_resolver *r); +static void unix_destroy(grpc_resolver *r); static void unix_maybe_finish_next_locked(unix_resolver *r); -static void unix_ref(grpc_resolver *r); -static void unix_unref(grpc_resolver *r); static void unix_shutdown(grpc_resolver *r); static void unix_channel_saw_error(grpc_resolver *r, struct sockaddr *failing_address, @@ -85,19 +83,7 @@ static void unix_next(grpc_resolver *r, grpc_client_config **target_config, grpc_iomgr_closure *on_complete); static const grpc_resolver_vtable unix_resolver_vtable = { - unix_ref, unix_unref, unix_shutdown, unix_channel_saw_error, unix_next}; - -static void unix_ref(grpc_resolver *resolver) { - unix_resolver *r = (unix_resolver *)resolver; - gpr_ref(&r->refs); -} - -static void unix_unref(grpc_resolver *resolver) { - unix_resolver *r = (unix_resolver *)resolver; - if (gpr_unref(&r->refs)) { - unix_destroy(r); - } -} + unix_destroy, unix_shutdown, unix_channel_saw_error, unix_next}; static void unix_shutdown(grpc_resolver *resolver) { unix_resolver *r = (unix_resolver *)resolver; @@ -149,7 +135,8 @@ static void unix_maybe_finish_next_locked(unix_resolver *r) { } } -static void unix_destroy(unix_resolver *r) { +static void unix_destroy(grpc_resolver *gr) { + unix_resolver *r = (unix_resolver*)gr; gpr_mu_destroy(&r->mu); grpc_subchannel_factory_unref(r->subchannel_factory); gpr_free(r); @@ -171,7 +158,7 @@ static grpc_resolver *unix_create( memset(r, 0, sizeof(*r)); gpr_ref_init(&r->refs, 1); gpr_mu_init(&r->mu); - r->base.vtable = &unix_resolver_vtable; + grpc_resolver_init(&r->base, &unix_resolver_vtable); r->subchannel_factory = subchannel_factory; r->lb_policy_factory = lb_policy_factory; diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index a0d21d99ebc..6f4bf2ebe8b 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -78,6 +78,8 @@ struct grpc_subchannel { size_t addr_len; /** metadata context */ grpc_mdctx *mdctx; + /** master channel */ + grpc_channel *master; /** set during connection */ grpc_connect_out_args connecting_result; @@ -217,6 +219,7 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, c->addr_len = args->addr_len; c->args = grpc_channel_args_copy(args->args); c->mdctx = args->mdctx; + c->master = args->master; grpc_mdctx_ref(c->mdctx); grpc_pollset_set_init(&c->pollset_set); grpc_iomgr_closure_init(&c->connected, subchannel_connected, c); @@ -267,6 +270,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, w4c->initial_op = *initial_op; w4c->target = target; w4c->subchannel = c; + /* released when clearing w4c */ subchannel_ref_locked(c); grpc_iomgr_closure_init(&w4c->continuation, continue_creating_call, w4c); c->waiting = w4c; @@ -274,6 +278,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, if (!c->connecting) { c->connecting = 1; connectivity_state_changed_locked(c); + /* released by connection */ subchannel_ref_locked(c); gpr_mu_unlock(&c->mu); @@ -301,6 +306,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, notify)) { do_connect = 1; c->connecting = 1; + /* released by connection */ subchannel_ref_locked(c); grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); @@ -313,7 +319,8 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, void grpc_subchannel_process_transport_op(grpc_subchannel *c, grpc_transport_op *op) { - abort(); /* not implemented */ + gpr_log(GPR_ERROR, "grpc_subchannel_process_transport_op not implemented"); + abort(); } static void on_state_changed(void *p, int iomgr_success) { @@ -357,6 +364,7 @@ static void on_state_changed(void *p, int iomgr_success) { break; case GRPC_CHANNEL_TRANSIENT_FAILURE: /* things are starting to go wrong, reconnect but don't deactivate */ + /* released by connection */ subchannel_ref_locked(c); do_connect = 1; c->connecting = 1; @@ -406,8 +414,9 @@ static void publish_transport(grpc_subchannel *c) { stk = (grpc_channel_stack *)(con + 1); con->refs = 0; con->subchannel = c; - grpc_channel_stack_init(filters, num_filters, c->args, c->mdctx, stk); + grpc_channel_stack_init(filters, num_filters, c->master, c->args, c->mdctx, stk); grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); + gpr_free(c->connecting_result.filters); memset(&c->connecting_result, 0, sizeof(c->connecting_result)); /* initialize state watcher */ diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index b777e51d201..766258846a4 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -90,6 +90,8 @@ struct grpc_subchannel_args { size_t addr_len; /** metadata context to use */ grpc_mdctx *mdctx; + /** master channel */ + grpc_channel *master; }; /** create a subchannel given a connector */ diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c index 2765706de8c..8fbddd73b0f 100644 --- a/src/core/iomgr/iomgr.c +++ b/src/core/iomgr/iomgr.c @@ -201,10 +201,21 @@ void grpc_iomgr_closure_init(grpc_iomgr_closure *closure, grpc_iomgr_cb_func cb, closure->next = NULL; } +static void assert_not_scheduled_locked(grpc_iomgr_closure *closure) { +#ifndef NDEBUG + grpc_iomgr_closure *c; + + for (c = g_cbs_head; c; c = c->next) { + GPR_ASSERT(c != closure); + } +#endif +} + void grpc_iomgr_add_delayed_callback(grpc_iomgr_closure *closure, int success) { closure->success = success; GPR_ASSERT(closure->cb); gpr_mu_lock(&g_mu); + assert_not_scheduled_locked(closure); closure->next = NULL; if (!g_cbs_tail) { g_cbs_head = g_cbs_tail = closure; diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index 2c05f73df57..0bd370e457d 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -280,7 +280,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c index cf5ce4010e3..a92b46c85f7 100644 --- a/src/core/security/server_auth_filter.c +++ b/src/core/security/server_auth_filter.c @@ -88,7 +88,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { grpc_security_connector *sc = grpc_find_security_connector_in_args(args); diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 4857912b4f6..e85eaf2c056 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -109,8 +109,6 @@ grpc_channel *grpc_channel_create_from_filters( } channel->path_string = grpc_mdstr_from_string(mdctx, ":path"); channel->authority_string = grpc_mdstr_from_string(mdctx, ":authority"); - grpc_channel_stack_init(filters, num_filters, args, channel->metadata_context, - CHANNEL_STACK_FROM_CHANNEL(channel)); gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = NULL; @@ -131,6 +129,9 @@ grpc_channel *grpc_channel_create_from_filters( } } + grpc_channel_stack_init(filters, num_filters, channel, args, channel->metadata_context, + CHANNEL_STACK_FROM_CHANNEL(channel)); + return channel; } @@ -237,6 +238,13 @@ void grpc_channel_internal_unref(grpc_channel *channel) { } void grpc_channel_destroy(grpc_channel *channel) { + grpc_transport_op op; + grpc_channel_element *elem; + memset(&op, 0, sizeof(op)); + op.disconnect = 1; + elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0); + elem->filter->start_transport_op(elem, &op); + GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel"); } diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 494a44725ad..0d756a131e4 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -155,6 +155,7 @@ grpc_channel *grpc_channel_create(const char *target, f = gpr_malloc(sizeof(*f)); f->base.vtable = &subchannel_factory_vtable; gpr_ref_init(&f->refs, 1); + grpc_mdctx_ref(mdctx); f->mdctx = mdctx; resolver = grpc_resolver_create(target, &f->base); if (!resolver) { @@ -163,7 +164,8 @@ grpc_channel *grpc_channel_create(const char *target, channel = grpc_channel_create_from_filters(filters, n, args, mdctx, 1); grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); - grpc_resolver_unref(resolver); + GRPC_RESOLVER_UNREF(resolver, "create"); + grpc_subchannel_factory_unref(&f->base); return channel; } diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index 5235d3f7f41..c6ac6798716 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -105,7 +105,7 @@ static void init_call_elem(grpc_call_element *elem, static void destroy_call_elem(grpc_call_element *elem) {} -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { channel_data *chand = elem->channel_data; diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 6d06725bf3a..f7d385c7afe 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -709,7 +709,7 @@ static void destroy_call_elem(grpc_call_element *elem) { server_unref(chand->server); } -static void init_channel_elem(grpc_channel_element *elem, +static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { diff --git a/src/core/transport/connectivity_state.c b/src/core/transport/connectivity_state.c index 5cbd67ef3c8..8df08af32f3 100644 --- a/src/core/transport/connectivity_state.c +++ b/src/core/transport/connectivity_state.c @@ -33,15 +33,18 @@ #include "src/core/transport/connectivity_state.h" #include +#include void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state init_state) { tracker->current_state = init_state; tracker->watchers = NULL; + /*gpr_log(GPR_DEBUG, "CS:%p:init:%d", tracker, init_state);*/ } void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker) { grpc_connectivity_state_watcher *w; + /*gpr_log(GPR_DEBUG, "CS:%p:destroy", tracker);*/ while ((w = tracker->watchers)) { tracker->watchers = w->next; @@ -80,6 +83,7 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state) { grpc_connectivity_state_watcher *new = NULL; grpc_connectivity_state_watcher *w; + /*gpr_log(GPR_DEBUG, "CS:%p:set:%d", tracker, state);*/ if (tracker->current_state == state) { return; } diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index ba778c37758..55a15a1a549 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -39,7 +39,7 @@ #include #include "test/core/util/test_config.h" -static void channel_init_func(grpc_channel_element *elem, +static void channel_init_func(grpc_channel_element *elem,grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { @@ -98,7 +98,7 @@ static void test_create_channel_stack(void) { chan_args.args = &arg; channel_stack = gpr_malloc(grpc_channel_stack_size(&filters, 1)); - grpc_channel_stack_init(&filters, 1, &chan_args, metadata_context, + grpc_channel_stack_init(&filters, 1, NULL, &chan_args, metadata_context, channel_stack); GPR_ASSERT(channel_stack->count == 1); channel_elem = grpc_channel_stack_element(channel_stack, 0); diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index fac06023282..0bfedca0abf 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -105,7 +105,7 @@ static void test_invoke_request_with_flags( gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - gpr_timespec deadline = five_seconds_time(); + gpr_timespec deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_with_flags", NULL, NULL); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -156,6 +156,11 @@ static void test_invoke_request_with_flags( expectation = call_start_batch_expected_result; GPR_ASSERT(expectation == grpc_call_start_batch(c, ops, op - ops, tag(1))); + if (expectation == GRPC_CALL_OK) { + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); + } + gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); From c396753a367677a4f2a111a850c2290dd27e2047 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 14:59:38 -0700 Subject: [PATCH 061/124] Refcounting fixes --- src/core/channel/client_channel.c | 2 +- .../client_config/lb_policies/pick_first.c | 8 +- src/core/client_config/subchannel.c | 77 ++++++++++++------- src/core/client_config/subchannel.h | 24 +++++- 4 files changed, 76 insertions(+), 35 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index ee0d2cd9bda..d3d2f42ec1c 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -459,7 +459,7 @@ static void destroy_call_elem(grpc_call_element *elem) { case CALL_ACTIVE: subchannel_call = calld->subchannel_call; gpr_mu_unlock(&calld->mu_state); - grpc_subchannel_call_unref(subchannel_call); + GRPC_SUBCHANNEL_CALL_UNREF(subchannel_call, "client_channel"); break; case CALL_CREATED: case CALL_CANCELLED: diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index c94408200ba..a8e5b5cc4a5 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -77,7 +77,7 @@ void pf_destroy(grpc_lb_policy *pol) { pick_first_lb_policy *p = (pick_first_lb_policy *)pol; size_t i; for (i = 0; i < p->num_subchannels; i++) { - grpc_subchannel_unref(p->subchannels[i]); + GRPC_SUBCHANNEL_UNREF(p->subchannels[i], "pick_first"); } gpr_free(p->subchannels); gpr_mu_destroy(&p->mu); @@ -180,7 +180,7 @@ loop: p->checking_connectivity = grpc_subchannel_check_connectivity( p->subchannels[p->checking_subchannel]); p->num_subchannels--; - grpc_subchannel_unref(p->subchannels[p->num_subchannels]); + GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); add_interested_parties_locked(p); if (p->num_subchannels == 0) { abort(); @@ -206,13 +206,13 @@ static void pf_broadcast(grpc_lb_policy *pol, grpc_transport_op *op) { subchannels = gpr_malloc(n * sizeof(*subchannels)); for (i = 0; i < n; i++) { subchannels[i] = p->subchannels[i]; - grpc_subchannel_ref(subchannels[i]); + GRPC_SUBCHANNEL_REF(subchannels[i], "pf_broadcast"); } gpr_mu_unlock(&p->mu); for (i = 0; i < n; i++) { grpc_subchannel_process_transport_op(subchannels[i], op); - grpc_subchannel_unref(subchannels[i]); + GRPC_SUBCHANNEL_UNREF(subchannels[i], "pf_broadcast"); } gpr_free(subchannels); } diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 6f4bf2ebe8b..3d065761ab9 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -123,13 +123,29 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); static gpr_timespec compute_connect_deadline(grpc_subchannel *c); static void subchannel_connected(void *subchannel, int iomgr_success); -static void subchannel_ref_locked(grpc_subchannel *c); -static int subchannel_unref_locked(grpc_subchannel *c) GRPC_MUST_USE_RESULT; -static void connection_ref_locked(connection *c); -static grpc_subchannel *connection_unref_locked(connection *c) +static void subchannel_ref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +static int subchannel_unref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) GRPC_MUST_USE_RESULT; +static void connection_ref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +static grpc_subchannel *connection_unref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) GRPC_MUST_USE_RESULT; static void subchannel_destroy(grpc_subchannel *c); +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +#define SUBCHANNEL_REF_LOCKED(p, r) subchannel_ref_locked((p), __FILE__, __LINE__, (r)) +#define SUBCHANNEL_UNREF_LOCKED(p, r) subchannel_unref_locked((p), __FILE__, __LINE__, (r)) +#define CONNECTION_REF_LOCKED(p, r) connection_ref_locked((p), __FILE__, __LINE__, (r)) +#define CONNECTION_UNREF_LOCKED(p, r) connection_unref_locked((p), __FILE__, __LINE__, (r)) +#define REF_PASS_ARGS , file, line, reason +#define REF_LOG(name, p) gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "%s: %p ref %d -> %d %s", (name), (p), (p)->refs, (p)->refs + 1, reason) +#define UNREF_LOG(name, p) gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "%s: %p unref %d -> %d %s", (name), (p), (p)->refs, (p)->refs - 1, reason) +#else +#define SUBCHANNEL_REF_LOCKED(p, r) subchannel_ref_locked((p)) +#define SUBCHANNEL_UNREF_LOCKED(p, r) subchannel_unref_locked((p)) +#define CONNECTION_REF_LOCKED(p, r) connection_ref_locked((p), __FILE__, __LINE__, (r)) +#define CONNECTION_UNREF_LOCKED(p, r) connection_unref_locked((p), __FILE__, __LINE__, (r)) +#define REF_PASS_ARGS +#endif + /* * connection implementation */ @@ -140,14 +156,16 @@ static void connection_destroy(connection *c) { gpr_free(c); } -static void connection_ref_locked(connection *c) { - subchannel_ref_locked(c->subchannel); +static void connection_ref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { + REF_LOG("CONNECTION", c); + subchannel_ref_locked(c->subchannel REF_PASS_ARGS); ++c->refs; } -static grpc_subchannel *connection_unref_locked(connection *c) { +static grpc_subchannel *connection_unref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { grpc_subchannel *destroy = NULL; - if (subchannel_unref_locked(c->subchannel)) { + UNREF_LOG("CONNECTION", c); + if (subchannel_unref_locked(c->subchannel REF_PASS_ARGS)) { destroy = c->subchannel; } if (--c->refs == 0 && c->subchannel->active != c) { @@ -160,22 +178,26 @@ static grpc_subchannel *connection_unref_locked(connection *c) { * grpc_subchannel implementation */ -static void subchannel_ref_locked(grpc_subchannel *c) { ++c->refs; } +static void subchannel_ref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { + REF_LOG("SUBCHANNEL", c); + ++c->refs; +} -static int subchannel_unref_locked(grpc_subchannel *c) { +static int subchannel_unref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { + UNREF_LOG("SUBCHANNEL", c); return --c->refs == 0; } -void grpc_subchannel_ref(grpc_subchannel *c) { +void grpc_subchannel_ref(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { gpr_mu_lock(&c->mu); - subchannel_ref_locked(c); + subchannel_ref_locked(c REF_PASS_ARGS); gpr_mu_unlock(&c->mu); } -void grpc_subchannel_unref(grpc_subchannel *c) { +void grpc_subchannel_unref(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { int destroy; gpr_mu_lock(&c->mu); - destroy = subchannel_unref_locked(c); + destroy = subchannel_unref_locked(c REF_PASS_ARGS); gpr_mu_unlock(&c->mu); if (destroy) subchannel_destroy(c); } @@ -190,6 +212,7 @@ static void subchannel_destroy(grpc_subchannel *c) { grpc_mdctx_unref(c->mdctx); grpc_pollset_set_destroy(&c->pollset_set); grpc_connectivity_state_destroy(&c->state_tracker); + grpc_connector_unref(c->connector); gpr_free(c); } @@ -246,7 +269,7 @@ static void continue_creating_call(void *arg, int iomgr_success) { waiting_for_connect *w4c = arg; grpc_subchannel_create_call(w4c->subchannel, &w4c->initial_op, w4c->target, w4c->notify); - grpc_subchannel_unref(w4c->subchannel); + GRPC_SUBCHANNEL_UNREF(w4c->subchannel, "waiting_for_connect"); gpr_free(w4c); } @@ -258,7 +281,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, gpr_mu_lock(&c->mu); if (c->active != NULL) { con = c->active; - connection_ref_locked(con); + CONNECTION_REF_LOCKED(con, "call"); gpr_mu_unlock(&c->mu); *target = create_call(con, initial_op); @@ -271,7 +294,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, w4c->target = target; w4c->subchannel = c; /* released when clearing w4c */ - subchannel_ref_locked(c); + SUBCHANNEL_REF_LOCKED(c, "waiting_for_connect"); grpc_iomgr_closure_init(&w4c->continuation, continue_creating_call, w4c); c->waiting = w4c; grpc_subchannel_add_interested_party(c, initial_op->bind_pollset); @@ -279,7 +302,7 @@ void grpc_subchannel_create_call(grpc_subchannel *c, c->connecting = 1; connectivity_state_changed_locked(c); /* released by connection */ - subchannel_ref_locked(c); + SUBCHANNEL_REF_LOCKED(c, "connecting"); gpr_mu_unlock(&c->mu); start_connect(c); @@ -307,7 +330,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, do_connect = 1; c->connecting = 1; /* released by connection */ - subchannel_ref_locked(c); + SUBCHANNEL_REF_LOCKED(c, "connecting"); grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); } @@ -365,7 +388,7 @@ static void on_state_changed(void *p, int iomgr_success) { case GRPC_CHANNEL_TRANSIENT_FAILURE: /* things are starting to go wrong, reconnect but don't deactivate */ /* released by connection */ - subchannel_ref_locked(c); + SUBCHANNEL_REF_LOCKED(c, "connection"); do_connect = 1; c->connecting = 1; break; @@ -374,7 +397,7 @@ static void on_state_changed(void *p, int iomgr_success) { done: grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); - destroy = subchannel_unref_locked(c); + destroy = SUBCHANNEL_UNREF_LOCKED(c, "connection"); gpr_free(sw); gpr_mu_unlock(mu); if (do_connect) { @@ -468,7 +491,7 @@ static void subchannel_connected(void *arg, int iomgr_success) { } else { int destroy; gpr_mu_lock(&c->mu); - destroy = subchannel_unref_locked(c); + destroy = SUBCHANNEL_UNREF_LOCKED(c, "connection"); gpr_mu_unlock(&c->mu); if (destroy) subchannel_destroy(c); /* TODO(ctiller): retry after sleeping */ @@ -499,18 +522,20 @@ static void connectivity_state_changed_locked(grpc_subchannel *c) { * grpc_subchannel_call implementation */ -void grpc_subchannel_call_ref(grpc_subchannel_call *c) { gpr_ref(&c->refs); } +void grpc_subchannel_call_ref(grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { + gpr_ref(&c->refs); +} -void grpc_subchannel_call_unref(grpc_subchannel_call *c) { +void grpc_subchannel_call_unref(grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { if (gpr_unref(&c->refs)) { gpr_mu *mu = &c->connection->subchannel->mu; grpc_subchannel *destroy; grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(c)); gpr_mu_lock(mu); - destroy = connection_unref_locked(c->connection); + destroy = CONNECTION_UNREF_LOCKED(c->connection, "call"); gpr_mu_unlock(mu); gpr_free(c); - if (destroy) { + if (destroy != NULL) { subchannel_destroy(destroy); } } diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 766258846a4..97a64c488d7 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -43,10 +43,26 @@ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; -void grpc_subchannel_ref(grpc_subchannel *channel); -void grpc_subchannel_unref(grpc_subchannel *channel); -void grpc_subchannel_call_ref(grpc_subchannel_call *call); -void grpc_subchannel_call_unref(grpc_subchannel_call *call); +#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG + +#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG +#define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_CALL_REF(p, r) grpc_subchannel_call_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) grpc_subchannel_call_unref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS , const char *file, int line, const char *reason +#else +#define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p)) +#define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p)) +#define GRPC_SUBCHANNEL_CALL_REF(p, r) grpc_subchannel_call_ref((p)) +#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) grpc_subchannel_call_unref((p)) +#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS +#endif + +void grpc_subchannel_ref(grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_subchannel_unref(grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_subchannel_call_ref(grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_subchannel_call_unref(grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS); /** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, From b6fbf1d986331c8959e60a172fe922d9f864b03f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 15:25:49 -0700 Subject: [PATCH 062/124] Fix refcounting --- src/core/channel/client_channel.c | 1 - src/core/client_config/subchannel.c | 50 ++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index d3d2f42ec1c..6b60dc07cf7 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -402,7 +402,6 @@ static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op grpc_connectivity_state_set(&chand->state_tracker, GRPC_CHANNEL_FATAL_FAILURE); destroy_resolver = chand->resolver; chand->resolver = NULL; - op->disconnect = 0; } if (!is_empty(op, sizeof(*op))) { diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 3d065761ab9..eadeb0ef558 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -80,6 +80,8 @@ struct grpc_subchannel { grpc_mdctx *mdctx; /** master channel */ grpc_channel *master; + /** have we seen a disconnection? */ + int disconnected; /** set during connection */ grpc_connect_out_args connecting_result; @@ -152,6 +154,7 @@ static void subchannel_destroy(grpc_subchannel *c); static void connection_destroy(connection *c) { GPR_ASSERT(c->refs == 0); + gpr_log(GPR_DEBUG, "CONNECTION_DESTROY %p", c); grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CONNECTION(c)); gpr_free(c); } @@ -342,8 +345,32 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, void grpc_subchannel_process_transport_op(grpc_subchannel *c, grpc_transport_op *op) { - gpr_log(GPR_ERROR, "grpc_subchannel_process_transport_op not implemented"); - abort(); + connection *con = NULL; + grpc_subchannel *destroy; + gpr_mu_lock(&c->mu); + if (op->disconnect) { + c->disconnected = 1; + grpc_connectivity_state_set(&c->state_tracker, + compute_connectivity_locked(c)); + } + if (c->active != NULL) { + con = c->active; + CONNECTION_REF_LOCKED(con, "transport-op"); + } + gpr_mu_unlock(&c->mu); + + if (con != NULL) { + grpc_channel_stack *channel_stack = CHANNEL_STACK_FROM_CONNECTION(con); + grpc_channel_element *top_elem = grpc_channel_stack_element(channel_stack, 0); + top_elem->filter->start_transport_op(top_elem, op); + + gpr_mu_lock(&c->mu); + destroy = CONNECTION_UNREF_LOCKED(con, "transport-op"); + gpr_mu_unlock(&c->mu); + if (destroy) { + subchannel_destroy(destroy); + } + } } static void on_state_changed(void *p, int iomgr_success) { @@ -388,7 +415,7 @@ static void on_state_changed(void *p, int iomgr_success) { case GRPC_CHANNEL_TRANSIENT_FAILURE: /* things are starting to go wrong, reconnect but don't deactivate */ /* released by connection */ - SUBCHANNEL_REF_LOCKED(c, "connection"); + SUBCHANNEL_REF_LOCKED(c, "connecting"); do_connect = 1; c->connecting = 1; break; @@ -397,7 +424,7 @@ static void on_state_changed(void *p, int iomgr_success) { done: grpc_connectivity_state_set(&c->state_tracker, compute_connectivity_locked(c)); - destroy = SUBCHANNEL_UNREF_LOCKED(c, "connection"); + destroy = SUBCHANNEL_UNREF_LOCKED(c, "state_watcher"); gpr_free(sw); gpr_mu_unlock(mu); if (do_connect) { @@ -450,6 +477,14 @@ static void publish_transport(grpc_subchannel *c) { gpr_mu_lock(&c->mu); + if (c->disconnected) { + gpr_mu_unlock(&c->mu); + gpr_free(sw); + gpr_free(filters); + grpc_channel_stack_destroy(stk); + return; + } + /* publish */ if (c->active != NULL && c->active->refs == 0) { destroy_connection = c->active; @@ -464,6 +499,8 @@ static void publish_transport(grpc_subchannel *c) { memset(&op, 0, sizeof(op)); op.connectivity_state = &sw->connectivity_state; op.on_connectivity_state_change = &sw->closure; + SUBCHANNEL_REF_LOCKED(c, "state_watcher"); + GPR_ASSERT(!SUBCHANNEL_UNREF_LOCKED(c, "connecting")); elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(c->active), 0); elem->filter->start_transport_op(elem, &op); @@ -491,7 +528,7 @@ static void subchannel_connected(void *arg, int iomgr_success) { } else { int destroy; gpr_mu_lock(&c->mu); - destroy = SUBCHANNEL_UNREF_LOCKED(c, "connection"); + destroy = SUBCHANNEL_UNREF_LOCKED(c, "connecting"); gpr_mu_unlock(&c->mu); if (destroy) subchannel_destroy(c); /* TODO(ctiller): retry after sleeping */ @@ -504,6 +541,9 @@ static gpr_timespec compute_connect_deadline(grpc_subchannel *c) { } static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { + if (c->disconnected) { + return GRPC_CHANNEL_FATAL_FAILURE; + } if (c->connecting) { return GRPC_CHANNEL_CONNECTING; } From d9a50886041fbd57e228b0b41d259029a576d589 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 15:57:36 -0700 Subject: [PATCH 063/124] SSL channel args work with client config again --- src/core/channel/channel_args.c | 18 +++++++++++++----- src/core/channel/channel_args.h | 4 +++- src/core/security/client_auth_filter.c | 1 - src/core/security/credentials.c | 2 +- src/core/security/server_secure_chttp2.c | 2 +- src/core/surface/channel_create.c | 6 ++++++ src/core/surface/secure_channel_create.c | 18 ++++++++++++++---- .../fixtures/chttp2_simple_ssl_fullstack.c | 2 +- .../chttp2_simple_ssl_fullstack_with_poll.c | 2 +- .../chttp2_simple_ssl_with_oauth2_fullstack.c | 2 +- 10 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/core/channel/channel_args.c b/src/core/channel/channel_args.c index 166d559a456..371da4210ee 100644 --- a/src/core/channel/channel_args.c +++ b/src/core/channel/channel_args.c @@ -62,7 +62,8 @@ static grpc_arg copy_arg(const grpc_arg *src) { } grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src, - const grpc_arg *to_add) { + const grpc_arg *to_add, + size_t num_to_add) { grpc_channel_args *dst = gpr_malloc(sizeof(grpc_channel_args)); size_t i; size_t src_num_args = (src == NULL) ? 0 : src->num_args; @@ -71,17 +72,24 @@ grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src, dst->args = NULL; return dst; } - dst->num_args = src_num_args + ((to_add == NULL) ? 0 : 1); + dst->num_args = src_num_args + num_to_add; dst->args = gpr_malloc(sizeof(grpc_arg) * dst->num_args); for (i = 0; i < src_num_args; i++) { dst->args[i] = copy_arg(&src->args[i]); } - if (to_add != NULL) dst->args[src_num_args] = copy_arg(to_add); + for (i = 0; i < num_to_add; i++) { + dst->args[i + src_num_args] = copy_arg(&to_add[i]); + } return dst; } grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src) { - return grpc_channel_args_copy_and_add(src, NULL); + return grpc_channel_args_copy_and_add(src, NULL, 0); +} + +grpc_channel_args *grpc_channel_args_merge(const grpc_channel_args *a, + const grpc_channel_args *b) { + return grpc_channel_args_copy_and_add(a, b->args, b->num_args); } void grpc_channel_args_destroy(grpc_channel_args *a) { @@ -137,5 +145,5 @@ void grpc_channel_args_set_compression_level( tmp.type = GRPC_ARG_INTEGER; tmp.key = GRPC_COMPRESSION_LEVEL_ARG; tmp.value.integer = level; - *a = grpc_channel_args_copy_and_add(*a, &tmp); + *a = grpc_channel_args_copy_and_add(*a, &tmp, 1); } diff --git a/src/core/channel/channel_args.h b/src/core/channel/channel_args.h index 41f3a554d6c..27ad57b3e8f 100644 --- a/src/core/channel/channel_args.h +++ b/src/core/channel/channel_args.h @@ -43,8 +43,10 @@ grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src); /** Copy some arguments and add the to_add parameter in the end. If to_add is NULL, it is equivalent to call grpc_channel_args_copy. */ grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src, - const grpc_arg *to_add); + const grpc_arg *to_add, + size_t num_to_add); +/** Copy args from a then args from b into a new channel args */ grpc_channel_args *grpc_channel_args_merge(const grpc_channel_args *a, const grpc_channel_args *b); /** Destroy arguments created by grpc_channel_args_copy */ diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index 0bd370e457d..93bf846978c 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -291,7 +291,6 @@ static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, /* The first and the last filters tend to be implemented differently to handle the case that there's no 'next' filter to call on the up or down path */ - GPR_ASSERT(!is_first); GPR_ASSERT(!is_last); GPR_ASSERT(sc != NULL); diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c index cf663faf2d0..e79e9ce3516 100644 --- a/src/core/security/credentials.c +++ b/src/core/security/credentials.c @@ -225,7 +225,7 @@ static grpc_security_status ssl_create_security_connector( arg.type = GRPC_ARG_STRING; arg.key = GRPC_ARG_HTTP2_SCHEME; arg.value.string = "https"; - *new_args = grpc_channel_args_copy_and_add(args, &arg); + *new_args = grpc_channel_args_copy_and_add(args, &arg, 1); return status; } diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c index d76bd86337d..018ec3d1d7f 100644 --- a/src/core/security/server_secure_chttp2.c +++ b/src/core/security/server_secure_chttp2.c @@ -83,7 +83,7 @@ static void setup_transport(void *statep, grpc_server_secure_state *state = statep; grpc_arg connector_arg = grpc_security_connector_to_arg(state->sc); grpc_channel_args *args_copy = grpc_channel_args_copy_and_add( - grpc_server_get_channel_args(state->server), &connector_arg); + grpc_server_get_channel_args(state->server), &connector_arg, 1); grpc_server_setup_transport(state->server, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), mdctx, args_copy); diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 0d756a131e4..6b559e1fb42 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -102,6 +102,7 @@ typedef struct { grpc_subchannel_factory base; gpr_refcount refs; grpc_mdctx *mdctx; + grpc_channel_args *merge_args; } subchannel_factory; static void subchannel_factory_ref(grpc_subchannel_factory *scf) { @@ -120,13 +121,17 @@ static void subchannel_factory_unref(grpc_subchannel_factory *scf) { static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { subchannel_factory *f = (subchannel_factory *)scf; connector *c = gpr_malloc(sizeof(*c)); + grpc_channel_args *final_args = + grpc_channel_args_merge(args->args, f->merge_args); grpc_subchannel *s; memset(c, 0, sizeof(*c)); c->base.vtable = &connector_vtable; gpr_ref_init(&c->refs, 1); args->mdctx = f->mdctx; + args->args = final_args; s = grpc_subchannel_create(&c->base, args); grpc_connector_unref(&c->base); + grpc_channel_args_destroy(final_args); return s; } @@ -157,6 +162,7 @@ grpc_channel *grpc_channel_create(const char *target, gpr_ref_init(&f->refs, 1); grpc_mdctx_ref(mdctx); f->mdctx = mdctx; + f->merge_args = grpc_channel_args_copy(args); resolver = grpc_resolver_create(target, &f->base); if (!resolver) { return NULL; diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index ad11c3954be..b60f390370b 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -81,14 +81,18 @@ static void on_secure_transport_setup_done(void *arg, if (status != GRPC_SECURITY_OK) { gpr_log(GPR_ERROR, "Secure transport setup failed with error %d.", status); memset(c->result, 0, sizeof(*c->result)); - notify = c->notify; - c->notify = NULL; - grpc_iomgr_add_callback(notify); } else { c->result->transport = grpc_create_chttp2_transport( c->args.channel_args, secure_endpoint, NULL, 0, c->args.metadata_context, 1); + c->result->filters = gpr_malloc(sizeof(grpc_channel_filter *) * 2); + c->result->filters[0] = &grpc_client_auth_filter; + c->result->filters[1] = &grpc_http_client_filter; + c->result->num_filters = 2; } + notify = c->notify; + c->notify = NULL; + grpc_iomgr_add_callback(notify); } static void connected(void *arg, grpc_endpoint *tcp) { @@ -123,6 +127,7 @@ typedef struct { grpc_subchannel_factory base; gpr_refcount refs; grpc_mdctx *mdctx; + grpc_channel_args *merge_args; grpc_channel_security_connector *security_connector; } subchannel_factory; @@ -142,14 +147,18 @@ static void subchannel_factory_unref(grpc_subchannel_factory *scf) { static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { subchannel_factory *f = (subchannel_factory *)scf; connector *c = gpr_malloc(sizeof(*c)); + grpc_channel_args *final_args = + grpc_channel_args_merge(args->args, f->merge_args); grpc_subchannel *s; memset(c, 0, sizeof(*c)); c->base.vtable = &connector_vtable; c->security_connector = f->security_connector; gpr_ref_init(&c->refs, 1); args->mdctx = f->mdctx; + args->args = final_args; s = grpc_subchannel_create(&c->base, args); grpc_connector_unref(&c->base); + grpc_channel_args_destroy(final_args); return s; } @@ -334,7 +343,7 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, connector_arg = grpc_security_connector_to_arg(&connector->base); args_copy = grpc_channel_args_copy_and_add( new_args_from_connector != NULL ? new_args_from_connector : args, - &connector_arg); + &connector_arg, 1); /* TODO(census) if (grpc_channel_args_is_census_enabled(args)) { filters[n++] = &grpc_client_census_filter; @@ -347,6 +356,7 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, gpr_ref_init(&f->refs, 1); f->mdctx = mdctx; f->security_connector = connector; + f->merge_args = grpc_channel_args_copy(args_copy); resolver = grpc_resolver_create(target, &f->base); if (!resolver) { return NULL; diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c index 237d0727021..73a36116fb1 100644 --- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c @@ -105,7 +105,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack( GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; grpc_channel_args *new_client_args = - grpc_channel_args_copy_and_add(client_args, &ssl_name_override); + grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); grpc_channel_args_destroy(new_client_args); } diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c index ff5642642de..b1ac3e535f1 100644 --- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c +++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c @@ -105,7 +105,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack( GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; grpc_channel_args *new_client_args = - grpc_channel_args_copy_and_add(client_args, &ssl_name_override); + grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); grpc_channel_args_destroy(new_client_args); } diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c index d4bb5d3ef56..de418bf7ee0 100644 --- a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c @@ -108,7 +108,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; grpc_channel_args *new_client_args = - grpc_channel_args_copy_and_add(client_args, &ssl_name_override); + grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds); grpc_channel_args_destroy(new_client_args); grpc_credentials_release(ssl_creds); From abf36389d446bc6ac2f5a067d9ae8174123b7686 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 16:13:27 -0700 Subject: [PATCH 064/124] Make SSL work --- src/core/channel/client_channel.c | 7 +++---- .../client_config/resolvers/dns_resolver.c | 4 +++- src/core/client_config/subchannel.c | 21 ++++++++----------- src/core/client_config/subchannel.h | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 6b60dc07cf7..d465a970b9b 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -198,7 +198,7 @@ static void started_call(void *arg, int iomgr_success) { static void picked_target(void *arg, int iomgr_success) { call_data *calld = arg; - grpc_transport_stream_op op; + grpc_pollset *pollset; if (calld->picked_channel == NULL) { /* treat this like a cancellation */ @@ -212,11 +212,10 @@ static void picked_target(void *arg, int iomgr_success) { } else { GPR_ASSERT(calld->state == CALL_WAITING_FOR_PICK); calld->state = CALL_WAITING_FOR_CALL; - op = calld->waiting_op; - memset(&calld->waiting_op, 0, sizeof(calld->waiting_op)); + pollset = calld->waiting_op.bind_pollset; gpr_mu_unlock(&calld->mu_state); grpc_iomgr_closure_init(&calld->async_setup_task, started_call, calld); - grpc_subchannel_create_call(calld->picked_channel, &op, + grpc_subchannel_create_call(calld->picked_channel, pollset, &calld->subchannel_call, &calld->async_setup_task); } diff --git a/src/core/client_config/resolvers/dns_resolver.c b/src/core/client_config/resolvers/dns_resolver.c index c64491ae51b..ac401bc4d35 100644 --- a/src/core/client_config/resolvers/dns_resolver.c +++ b/src/core/client_config/resolvers/dns_resolver.c @@ -173,7 +173,9 @@ static void dns_maybe_finish_next_locked(dns_resolver *r) { if (r->next_completion != NULL && r->resolved_version != r->published_version) { *r->target_config = r->resolved_config; - grpc_client_config_ref(r->resolved_config); + if (r->resolved_config) { + grpc_client_config_ref(r->resolved_config); + } grpc_iomgr_add_callback(r->next_completion); r->next_completion = NULL; r->published_version = r->resolved_version; diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index eadeb0ef558..b5e991a5944 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -59,7 +59,7 @@ typedef struct { typedef struct waiting_for_connect { struct waiting_for_connect *next; grpc_iomgr_closure *notify; - grpc_transport_stream_op initial_op; + grpc_pollset *pollset; grpc_subchannel_call **target; grpc_subchannel *subchannel; grpc_iomgr_closure continuation; @@ -118,8 +118,7 @@ struct grpc_subchannel_call { #define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack *)((call) + 1)) #define CHANNEL_STACK_FROM_CONNECTION(con) ((grpc_channel_stack *)((con) + 1)) -static grpc_subchannel_call *create_call(connection *con, - grpc_transport_stream_op *initial_op); +static grpc_subchannel_call *create_call(connection *con); static void connectivity_state_changed_locked(grpc_subchannel *c); static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); static gpr_timespec compute_connect_deadline(grpc_subchannel *c); @@ -270,14 +269,13 @@ static void start_connect(grpc_subchannel *c) { static void continue_creating_call(void *arg, int iomgr_success) { waiting_for_connect *w4c = arg; - grpc_subchannel_create_call(w4c->subchannel, &w4c->initial_op, w4c->target, + grpc_subchannel_create_call(w4c->subchannel, w4c->pollset, w4c->target, w4c->notify); GRPC_SUBCHANNEL_UNREF(w4c->subchannel, "waiting_for_connect"); gpr_free(w4c); } -void grpc_subchannel_create_call(grpc_subchannel *c, - grpc_transport_stream_op *initial_op, +void grpc_subchannel_create_call(grpc_subchannel *c, grpc_pollset *pollset, grpc_subchannel_call **target, grpc_iomgr_closure *notify) { connection *con; @@ -287,20 +285,20 @@ void grpc_subchannel_create_call(grpc_subchannel *c, CONNECTION_REF_LOCKED(con, "call"); gpr_mu_unlock(&c->mu); - *target = create_call(con, initial_op); + *target = create_call(con); notify->cb(notify->cb_arg, 1); } else { waiting_for_connect *w4c = gpr_malloc(sizeof(*w4c)); w4c->next = c->waiting; w4c->notify = notify; - w4c->initial_op = *initial_op; + w4c->pollset = pollset; w4c->target = target; w4c->subchannel = c; /* released when clearing w4c */ SUBCHANNEL_REF_LOCKED(c, "waiting_for_connect"); grpc_iomgr_closure_init(&w4c->continuation, continue_creating_call, w4c); c->waiting = w4c; - grpc_subchannel_add_interested_party(c, initial_op->bind_pollset); + grpc_subchannel_add_interested_party(c, pollset); if (!c->connecting) { c->connecting = 1; connectivity_state_changed_locked(c); @@ -588,14 +586,13 @@ void grpc_subchannel_call_process_op(grpc_subchannel_call *call, top_elem->filter->start_transport_stream_op(top_elem, op); } -grpc_subchannel_call *create_call(connection *con, - grpc_transport_stream_op *initial_op) { +grpc_subchannel_call *create_call(connection *con) { grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con); grpc_subchannel_call *call = gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size); grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(call); call->connection = con; gpr_ref_init(&call->refs, 1); - grpc_call_stack_init(chanstk, NULL, initial_op, callstk); + grpc_call_stack_init(chanstk, NULL, NULL, callstk); return call; } diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 97a64c488d7..03bd4f63e01 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -66,7 +66,7 @@ void grpc_subchannel_call_unref(grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_E /** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, - grpc_transport_stream_op *initial_op, + grpc_pollset *pollset, grpc_subchannel_call **target, grpc_iomgr_closure *notify); From 11bf14ec333e02cabef50d7ea61c52aa009d71b6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 16:35:41 -0700 Subject: [PATCH 065/124] Trip through transient failure on disconnection --- include/grpc/grpc.h | 4 ++-- src/core/client_config/subchannel.c | 28 +++++++++++++++++++--------- src/core/client_config/subchannel.h | 2 -- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index a24506a8a54..147343049b5 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -120,14 +120,14 @@ typedef struct { /** Connectivity state of a channel. */ typedef enum { + /** channel is idle */ + GRPC_CHANNEL_IDLE, /** channel is connecting */ GRPC_CHANNEL_CONNECTING, /** channel is ready for work */ GRPC_CHANNEL_READY, /** channel has seen a failure but expects to recover */ GRPC_CHANNEL_TRANSIENT_FAILURE, - /** channel is idle */ - GRPC_CHANNEL_IDLE, /** channel has seen a failure that it cannot recover from */ GRPC_CHANNEL_FATAL_FAILURE } grpc_connectivity_state; diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index b5e991a5944..19ec1c0b4ba 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -142,9 +142,15 @@ static void subchannel_destroy(grpc_subchannel *c); #else #define SUBCHANNEL_REF_LOCKED(p, r) subchannel_ref_locked((p)) #define SUBCHANNEL_UNREF_LOCKED(p, r) subchannel_unref_locked((p)) -#define CONNECTION_REF_LOCKED(p, r) connection_ref_locked((p), __FILE__, __LINE__, (r)) -#define CONNECTION_UNREF_LOCKED(p, r) connection_unref_locked((p), __FILE__, __LINE__, (r)) +#define CONNECTION_REF_LOCKED(p, r) connection_ref_locked((p)) +#define CONNECTION_UNREF_LOCKED(p, r) connection_unref_locked((p)) #define REF_PASS_ARGS +#define REF_LOG(name, p) \ + do { \ + } while (0) +#define UNREF_LOG(name, p) \ + do { \ + } while (0) #endif /* @@ -332,8 +338,7 @@ void grpc_subchannel_notify_on_state_change(grpc_subchannel *c, c->connecting = 1; /* released by connection */ SUBCHANNEL_REF_LOCKED(c, "connecting"); - grpc_connectivity_state_set(&c->state_tracker, - compute_connectivity_locked(c)); + connectivity_state_changed_locked(c); } gpr_mu_unlock(&c->mu); if (do_connect) { @@ -348,8 +353,7 @@ void grpc_subchannel_process_transport_op(grpc_subchannel *c, gpr_mu_lock(&c->mu); if (op->disconnect) { c->disconnected = 1; - grpc_connectivity_state_set(&c->state_tracker, - compute_connectivity_locked(c)); + connectivity_state_changed_locked(c); } if (c->active != NULL) { con = c->active; @@ -389,6 +393,8 @@ static void on_state_changed(void *p, int iomgr_success) { goto done; } + gpr_log(GPR_DEBUG, "TRANSPORT STATE: %d", sw->connectivity_state); + switch (sw->connectivity_state) { case GRPC_CHANNEL_CONNECTING: case GRPC_CHANNEL_READY: @@ -409,19 +415,22 @@ static void on_state_changed(void *p, int iomgr_success) { destroy_connection = sw->subchannel->active; } sw->subchannel->active = NULL; + grpc_connectivity_state_set(&c->state_tracker, + GRPC_CHANNEL_TRANSIENT_FAILURE); break; case GRPC_CHANNEL_TRANSIENT_FAILURE: /* things are starting to go wrong, reconnect but don't deactivate */ /* released by connection */ SUBCHANNEL_REF_LOCKED(c, "connecting"); + grpc_connectivity_state_set(&c->state_tracker, + GRPC_CHANNEL_TRANSIENT_FAILURE); do_connect = 1; c->connecting = 1; break; } done: - grpc_connectivity_state_set(&c->state_tracker, - compute_connectivity_locked(c)); + connectivity_state_changed_locked(c); destroy = SUBCHANNEL_UNREF_LOCKED(c, "state_watcher"); gpr_free(sw); gpr_mu_unlock(mu); @@ -521,7 +530,7 @@ static void publish_transport(grpc_subchannel *c) { static void subchannel_connected(void *arg, int iomgr_success) { grpc_subchannel *c = arg; - if (c->connecting_result.transport) { + if (c->connecting_result.transport != NULL) { publish_transport(c); } else { int destroy; @@ -553,6 +562,7 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { static void connectivity_state_changed_locked(grpc_subchannel *c) { grpc_connectivity_state current = compute_connectivity_locked(c); + gpr_log(GPR_DEBUG, "SUBCHANNEL constate=%d", current); grpc_connectivity_state_set(&c->state_tracker, current); } diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 03bd4f63e01..5435ef703b3 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -43,8 +43,6 @@ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; -#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG - #ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG #define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p), __FILE__, __LINE__, (r)) #define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p), __FILE__, __LINE__, (r)) From ff3ae687e1e85d4fb29024c20a17595dce05e51f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 17:44:04 -0700 Subject: [PATCH 066/124] Add connect retry, backoff --- src/core/client_config/subchannel.c | 50 ++++++- src/core/client_config/subchannel.h | 2 + src/core/surface/server.c | 180 ++++++++++++------------ src/core/transport/chttp2/internal.h | 3 +- src/core/transport/chttp2_transport.c | 38 +++-- src/core/transport/connectivity_state.c | 17 ++- src/core/transport/connectivity_state.h | 4 + 7 files changed, 182 insertions(+), 112 deletions(-) diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 19ec1c0b4ba..c8c562f29d8 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -39,6 +39,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/channel/connected_channel.h" +#include "src/core/iomgr/alarm.h" #include "src/core/transport/connectivity_state.h" typedef struct { @@ -108,6 +109,15 @@ struct grpc_subchannel { waiting_for_connect *waiting; /** connectivity state tracking */ grpc_connectivity_state_tracker state_tracker; + + /** next connect attempt time */ + gpr_timespec next_attempt; + /** amount to backoff each failure */ + gpr_timespec backoff_delta; + /** do we have an active alarm? */ + int have_alarm; + /** our alarm */ + grpc_alarm alarm; }; struct grpc_subchannel_call { @@ -259,7 +269,7 @@ grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, return c; } -static void start_connect(grpc_subchannel *c) { +static void continue_connect(grpc_subchannel *c) { grpc_connect_in_args args; args.interested_parties = &c->pollset_set; @@ -273,6 +283,14 @@ static void start_connect(grpc_subchannel *c) { &c->connected); } +static void start_connect(grpc_subchannel *c) { + gpr_timespec now = gpr_now(); + c->next_attempt = now; + c->backoff_delta = gpr_time_from_seconds(1); + + continue_connect(c); +} + static void continue_creating_call(void *arg, int iomgr_success) { waiting_for_connect *w4c = arg; grpc_subchannel_create_call(w4c->subchannel, w4c->pollset, w4c->target, @@ -350,10 +368,14 @@ void grpc_subchannel_process_transport_op(grpc_subchannel *c, grpc_transport_op *op) { connection *con = NULL; grpc_subchannel *destroy; + int cancel_alarm = 0; gpr_mu_lock(&c->mu); if (op->disconnect) { c->disconnected = 1; connectivity_state_changed_locked(c); + if (c->have_alarm) { + cancel_alarm = 1; + } } if (c->active != NULL) { con = c->active; @@ -373,6 +395,10 @@ void grpc_subchannel_process_transport_op(grpc_subchannel *c, subchannel_destroy(destroy); } } + + if (cancel_alarm) { + grpc_alarm_cancel(&c->alarm); + } } static void on_state_changed(void *p, int iomgr_success) { @@ -528,18 +554,30 @@ static void publish_transport(grpc_subchannel *c) { } } +static void on_alarm(void *arg, int iomgr_success) { + grpc_subchannel *c = arg; + gpr_mu_lock(&c->mu); + c->have_alarm = 0; + gpr_mu_unlock(&c->mu); + if (iomgr_success) { + continue_connect(c); + } else { + GRPC_SUBCHANNEL_UNREF(c, "connecting"); + } +} + static void subchannel_connected(void *arg, int iomgr_success) { grpc_subchannel *c = arg; if (c->connecting_result.transport != NULL) { publish_transport(c); } else { - int destroy; gpr_mu_lock(&c->mu); - destroy = SUBCHANNEL_UNREF_LOCKED(c, "connecting"); + GPR_ASSERT(!c->have_alarm); + c->have_alarm = 1; + c->next_attempt = gpr_time_add(c->next_attempt, c->backoff_delta); + c->backoff_delta = gpr_time_add(c->backoff_delta, c->backoff_delta); + grpc_alarm_init(&c->alarm, c->next_attempt, on_alarm, c, gpr_now()); gpr_mu_unlock(&c->mu); - if (destroy) subchannel_destroy(c); - /* TODO(ctiller): retry after sleeping */ - abort(); } } diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 5435ef703b3..03bd4f63e01 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -43,6 +43,8 @@ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; +#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG + #ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG #define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p), __FILE__, __LINE__, (r)) #define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p), __FILE__, __LINE__, (r)) diff --git a/src/core/surface/server.c b/src/core/surface/server.c index f7d385c7afe..383c3d921dd 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -202,18 +202,86 @@ struct call_data { call_link links[CALL_LIST_COUNT]; }; +typedef struct { + grpc_channel **channels; + size_t num_channels; +} channel_broadcaster; + #define SERVER_FROM_CALL_ELEM(elem) \ (((channel_data *)(elem)->channel_data)->server) static void begin_call(grpc_server *server, call_data *calld, requested_call *rc); static void fail_call(grpc_server *server, requested_call *rc); -static void shutdown_channel(channel_data *chand, int send_goaway, - int send_disconnect); /* Before calling maybe_finish_shutdown, we must hold mu_global and not hold mu_call */ static void maybe_finish_shutdown(grpc_server *server); +/* channel broadcaster */ + +/* assumes server locked */ +static void channel_broadcaster_init(grpc_server *s, channel_broadcaster *cb) { + channel_data *c; + size_t count = 0; + for (c = s->root_channel_data.next; c != &s->root_channel_data; + c = c->next) { + count ++; + } + cb->num_channels = count; + cb->channels = gpr_malloc(sizeof(*cb->channels) * cb->num_channels); + count = 0; + for (c = s->root_channel_data.next; c != &s->root_channel_data; + c = c->next) { + cb->channels[count] = c->channel; + GRPC_CHANNEL_INTERNAL_REF(c->channel, "broadcast"); + count ++; + } +} + +struct shutdown_cleanup_args { + grpc_iomgr_closure closure; + gpr_slice slice; +}; + +static void shutdown_cleanup(void *arg, int iomgr_status_ignored) { + struct shutdown_cleanup_args *a = arg; + gpr_slice_unref(a->slice); + gpr_free(a); +} + +static void send_shutdown(grpc_channel *channel, int send_goaway, int send_disconnect) { + grpc_transport_op op; + struct shutdown_cleanup_args *sc; + grpc_channel_element *elem; + + memset(&op, 0, sizeof(op)); + gpr_log(GPR_DEBUG, "send_goaway:%d", send_goaway); + op.send_goaway = send_goaway; + sc = gpr_malloc(sizeof(*sc)); + sc->slice = gpr_slice_from_copied_string("Server shutdown"); + op.goaway_message = &sc->slice; + op.goaway_status = GRPC_STATUS_OK; + op.disconnect = send_disconnect; + grpc_iomgr_closure_init(&sc->closure, shutdown_cleanup, sc); + op.on_consumed = &sc->closure; + + elem = grpc_channel_stack_element( + grpc_channel_get_channel_stack(channel), 0); + elem->filter->start_transport_op(elem, &op); +} + +static void channel_broadcaster_shutdown(channel_broadcaster *cb, int send_goaway, int send_disconnect) { + size_t i; + + for (i = 0; i < cb->num_channels; i++) { + send_shutdown(cb->channels[i], send_goaway, send_disconnect); + GRPC_CHANNEL_INTERNAL_UNREF(cb->channels[i], "broadcast"); + } + gpr_free(cb->channels); +} + +/* call list */ + static int call_list_join(call_data **root, call_data *call, call_list list) { GPR_ASSERT(!call->root[list]); call->root[list] = root; @@ -458,12 +526,14 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { return md; } -static void decrement_call_count(channel_data *chand) { +static int decrement_call_count(channel_data *chand) { + int disconnect = 0; chand->num_calls--; if (0 == chand->num_calls && chand->server->shutdown) { - shutdown_channel(chand, 0, 1); + disconnect = 1; } maybe_finish_shutdown(chand->server); + return disconnect; } static void server_on_recv(void *ptr, int success) { @@ -471,6 +541,7 @@ static void server_on_recv(void *ptr, int success) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; int remove_res; + int disconnect = 0; if (success && !calld->got_initial_metadata) { size_t i; @@ -519,9 +590,16 @@ static void server_on_recv(void *ptr, int success) { gpr_mu_unlock(&chand->server->mu_call); gpr_mu_lock(&chand->server->mu_global); if (remove_res) { - decrement_call_count(chand); + disconnect = decrement_call_count(chand); + if (disconnect) { + GRPC_CHANNEL_INTERNAL_REF(chand->channel, "send-disconnect"); + } } gpr_mu_unlock(&chand->server->mu_global); + if (disconnect) { + send_shutdown(chand->channel, 0, 1); + GRPC_CHANNEL_INTERNAL_UNREF(chand->channel, "send-disconnect"); + } break; } @@ -575,89 +653,6 @@ static void channel_connectivity_changed(void *cd, int iomgr_status_ignored) { } } -#if 0 -static void channel_op(grpc_channel_element *elem, - grpc_channel_element *from_elem, grpc_channel_op *op) { - channel_data *chand = elem->channel_data; - grpc_server *server = chand->server; - - switch (op->type) { - case GRPC_ACCEPT_CALL: - /* create a call */ - grpc_call_create(chand->channel, NULL, - op->data.accept_call.transport_server_data, NULL, 0, - gpr_inf_future); - break; - case GRPC_TRANSPORT_CLOSED: - /* if the transport is closed for a server channel, we destroy the - channel */ - gpr_mu_lock(&server->mu_global); - server_ref(server); - destroy_channel(chand); - gpr_mu_unlock(&server->mu_global); - server_unref(server); - break; - case GRPC_TRANSPORT_GOAWAY: - gpr_slice_unref(op->data.goaway.message); - break; - default: - GPR_ASSERT(op->dir == GRPC_CALL_DOWN); - grpc_channel_next_op(elem, op); - break; - } -} -#endif - -typedef struct { - channel_data *chand; - int send_goaway; - int send_disconnect; - grpc_iomgr_closure finish_shutdown_channel_closure; - - /* for use during shutdown: the goaway message to send */ - gpr_slice goaway_message; -} shutdown_channel_args; - -static void destroy_shutdown_channel_args(void *p, int success) { - shutdown_channel_args *sca = p; - GRPC_CHANNEL_INTERNAL_UNREF(sca->chand->channel, "shutdown"); - gpr_slice_unref(sca->goaway_message); - gpr_free(sca); -} - -static void finish_shutdown_channel(void *p, int success) { - shutdown_channel_args *sca = p; - grpc_transport_op op; - memset(&op, 0, sizeof(op)); - - op.send_goaway = sca->send_goaway; - sca->goaway_message = gpr_slice_from_copied_string("Server shutdown"); - op.goaway_message = &sca->goaway_message; - op.goaway_status = GRPC_STATUS_OK; - op.disconnect = sca->send_disconnect; - grpc_iomgr_closure_init(&sca->finish_shutdown_channel_closure, - destroy_shutdown_channel_args, sca); - op.on_consumed = &sca->finish_shutdown_channel_closure; - - grpc_channel_next_op( - grpc_channel_stack_element( - grpc_channel_get_channel_stack(sca->chand->channel), 0), - &op); -} - -static void shutdown_channel(channel_data *chand, int send_goaway, - int send_disconnect) { - shutdown_channel_args *sca; - GRPC_CHANNEL_INTERNAL_REF(chand->channel, "shutdown"); - sca = gpr_malloc(sizeof(shutdown_channel_args)); - sca->chand = chand; - sca->send_goaway = send_goaway; - sca->send_disconnect = send_disconnect; - sca->finish_shutdown_channel_closure.cb = finish_shutdown_channel; - sca->finish_shutdown_channel_closure.cb_arg = sca; - grpc_iomgr_add_callback(&sca->finish_shutdown_channel_closure); -} - static void init_call_elem(grpc_call_element *elem, const void *server_transport_data, grpc_transport_stream_op *initial_op) { @@ -969,10 +964,10 @@ void grpc_server_shutdown_and_notify(grpc_server *server, grpc_completion_queue *cq, void *tag) { listener *l; requested_call_array requested_calls; - channel_data *c; size_t i; registered_method *rm; shutdown_tag *sdt; + channel_broadcaster broadcaster; /* lock, and gather up some stuff to do */ gpr_mu_lock(&server->mu_global); @@ -988,10 +983,7 @@ void grpc_server_shutdown_and_notify(grpc_server *server, return; } - for (c = server->root_channel_data.next; c != &server->root_channel_data; - c = c->next) { - shutdown_channel(c, 1, c->num_calls == 0); - } + channel_broadcaster_init(server, &broadcaster); /* collect all unregistered then registered calls */ gpr_mu_lock(&server->mu_call); @@ -1029,6 +1021,8 @@ void grpc_server_shutdown_and_notify(grpc_server *server, for (l = server->listeners; l; l = l->next) { l->destroy(server, l->arg); } + + channel_broadcaster_shutdown(&broadcaster, 1, 0); } void grpc_server_listener_destroy_done(void *s) { diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h index 7e2e75f97d2..c8c46f0e544 100644 --- a/src/core/transport/chttp2/internal.h +++ b/src/core/transport/chttp2/internal.h @@ -160,7 +160,8 @@ typedef struct { /** data to write next write */ gpr_slice_buffer qbuf; /** queued callbacks */ - grpc_iomgr_closure *pending_closures; + grpc_iomgr_closure *pending_closures_head; + grpc_iomgr_closure *pending_closures_tail; /** window available for us to send to peer */ gpr_uint32 outgoing_window; diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 8f909dff374..08a767f1d5b 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -117,6 +117,8 @@ static void add_to_pollset_locked(grpc_chttp2_transport *t, static void maybe_start_some_streams( grpc_chttp2_transport_global *transport_global); +static void connectivity_state_set(grpc_chttp2_transport_global *transport_global, grpc_connectivity_state state); + /* * CONSTRUCTION/DESTRUCTION/REFCOUNTING */ @@ -328,7 +330,7 @@ static void destroy_transport(grpc_transport *gt) { static void close_transport_locked(grpc_chttp2_transport *t) { if (!t->closed) { t->closed = 1; - grpc_connectivity_state_set(&t->channel_callback.state_tracker, + connectivity_state_set(&t->global, GRPC_CHANNEL_FATAL_FAILURE); if (t->ep) { grpc_endpoint_shutdown(t->ep); @@ -451,8 +453,9 @@ static void unlock(grpc_chttp2_transport *t) { grpc_chttp2_schedule_closure(&t->global, &t->writing_action, 1); } - run_closures = t->global.pending_closures; - t->global.pending_closures = NULL; + run_closures = t->global.pending_closures_head; + t->global.pending_closures_head = NULL; + t->global.pending_closures_tail = NULL; gpr_mu_unlock(&t->mu); @@ -523,8 +526,8 @@ void grpc_chttp2_add_incoming_goaway( gpr_free(msg); gpr_slice_unref(goaway_text); transport_global->seen_goaway = 1; - grpc_connectivity_state_set( - &TRANSPORT_FROM_GLOBAL(transport_global)->channel_callback.state_tracker, + connectivity_state_set( + transport_global, GRPC_CHANNEL_FATAL_FAILURE); } @@ -550,8 +553,7 @@ static void maybe_start_some_streams( transport_global->next_stream_id += 2; if (transport_global->next_stream_id >= MAX_CLIENT_STREAM_ID) { - grpc_connectivity_state_set(&TRANSPORT_FROM_GLOBAL(transport_global) - ->channel_callback.state_tracker, + connectivity_state_set(transport_global, GRPC_CHANNEL_TRANSIENT_FAILURE); } @@ -933,12 +935,30 @@ static void reading_action(void *pt, int iomgr_success_ignored) { * CALLBACK LOOP */ +static void schedule_closure_for_connectivity(void *a, grpc_iomgr_closure *closure) { + grpc_chttp2_schedule_closure(a, closure, 1); +} + +static void connectivity_state_set(grpc_chttp2_transport_global *transport_global, grpc_connectivity_state state) { + grpc_connectivity_state_set_with_scheduler( + &TRANSPORT_FROM_GLOBAL(transport_global)->channel_callback.state_tracker, + state, + schedule_closure_for_connectivity, + transport_global); +} + void grpc_chttp2_schedule_closure( grpc_chttp2_transport_global *transport_global, grpc_iomgr_closure *closure, int success) { closure->success = success; - closure->next = transport_global->pending_closures; - transport_global->pending_closures = closure; + if (transport_global->pending_closures_tail == NULL) { + transport_global->pending_closures_head = + transport_global->pending_closures_tail = closure; + } else { + transport_global->pending_closures_tail->next = closure; + transport_global->pending_closures_tail = closure; + } + closure->next = NULL; } /* diff --git a/src/core/transport/connectivity_state.c b/src/core/transport/connectivity_state.c index 8df08af32f3..9a956a5a588 100644 --- a/src/core/transport/connectivity_state.c +++ b/src/core/transport/connectivity_state.c @@ -79,8 +79,10 @@ int grpc_connectivity_state_notify_on_state_change( return tracker->current_state == GRPC_CHANNEL_IDLE; } -void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, - grpc_connectivity_state state) { +void grpc_connectivity_state_set_with_scheduler( + grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state, + void (*scheduler)(void *arg, grpc_iomgr_closure *closure), + void *arg) { grpc_connectivity_state_watcher *new = NULL; grpc_connectivity_state_watcher *w; /*gpr_log(GPR_DEBUG, "CS:%p:set:%d", tracker, state);*/ @@ -93,7 +95,7 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, if (state != *w->current) { *w->current = state; - grpc_iomgr_add_callback(w->notify); + scheduler(arg, w->notify); gpr_free(w); } else { w->next = new; @@ -102,3 +104,12 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, } tracker->watchers = new; } + +static void default_scheduler(void *ignored, grpc_iomgr_closure *closure) { + grpc_iomgr_add_callback(closure); +} + +void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, + grpc_connectivity_state state) { + grpc_connectivity_state_set_with_scheduler(tracker, state, default_scheduler, NULL); +} diff --git a/src/core/transport/connectivity_state.h b/src/core/transport/connectivity_state.h index 9a8c57525f0..c6f903a1ea6 100644 --- a/src/core/transport/connectivity_state.h +++ b/src/core/transport/connectivity_state.h @@ -59,6 +59,10 @@ void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker); void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state); +void grpc_connectivity_state_set_with_scheduler( + grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state, + void (*scheduler)(void *arg, grpc_iomgr_closure *closure), + void *arg); grpc_connectivity_state grpc_connectivity_state_check( grpc_connectivity_state_tracker *tracker); From 49924e0e62d29499874e93f5dcf5976edcf610f4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 29 Jun 2015 22:42:33 -0700 Subject: [PATCH 067/124] Better handling of cancellation, uri parse errors, and disconnection --- src/core/channel/client_channel.c | 4 +++ src/core/client_config/resolver_registry.c | 7 +++-- src/core/client_config/subchannel.c | 14 +-------- src/core/client_config/uri_parser.c | 36 ++++++++++++---------- src/core/client_config/uri_parser.h | 2 +- src/core/surface/server.c | 23 ++++++++++++-- src/core/transport/chttp2_transport.c | 4 +-- test/core/client_config/uri_parser_test.c | 4 +-- 8 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index d465a970b9b..e62a262babd 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -242,6 +242,7 @@ static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_ channel_data *chand = elem->channel_data; grpc_subchannel_call *subchannel_call; grpc_lb_policy *lb_policy; + grpc_transport_stream_op op2; GPR_ASSERT(elem->filter == &grpc_client_channel_filter); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); @@ -263,8 +264,11 @@ static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_ if (!continuation) { if (op->cancel_with_status != GRPC_STATUS_OK) { calld->state = CALL_CANCELLED; + op2 = calld->waiting_op; + memset(&calld->waiting_op, 0, sizeof(calld->waiting_op)); gpr_mu_unlock(&calld->mu_state); handle_op_after_cancellation(elem, op); + handle_op_after_cancellation(elem, &op2); } else { GPR_ASSERT((calld->waiting_op.send_ops == NULL) != (op->send_ops == NULL)); diff --git a/src/core/client_config/resolver_registry.c b/src/core/client_config/resolver_registry.c index abdb5f93775..16be2da9940 100644 --- a/src/core/client_config/resolver_registry.c +++ b/src/core/client_config/resolver_registry.c @@ -100,18 +100,21 @@ grpc_resolver *grpc_resolver_create( grpc_resolver_factory *factory = NULL; grpc_resolver *resolver; - uri = grpc_uri_parse(name); + uri = grpc_uri_parse(name, 1); factory = lookup_factory(uri); if (factory == NULL && g_default_resolver_scheme != NULL) { grpc_uri_destroy(uri); gpr_asprintf(&tmp, "%s%s", g_default_resolver_scheme, name); - uri = grpc_uri_parse(tmp); + uri = grpc_uri_parse(tmp, 1); factory = lookup_factory(uri); if (factory == NULL) { + grpc_uri_destroy(grpc_uri_parse(name, 0)); + grpc_uri_destroy(grpc_uri_parse(tmp, 0)); gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", name, tmp); } gpr_free(tmp); } else if (factory == NULL) { + grpc_uri_destroy(grpc_uri_parse(name, 0)); gpr_log(GPR_ERROR, "don't know how to resolve '%s'", name); } resolver = diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index c8c562f29d8..cae6db0110d 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -409,7 +409,6 @@ static void on_state_changed(void *p, int iomgr_success) { grpc_transport_op op; grpc_channel_element *elem; connection *destroy_connection = NULL; - int do_connect = 0; gpr_mu_lock(mu); @@ -436,6 +435,7 @@ static void on_state_changed(void *p, int iomgr_success) { gpr_mu_unlock(mu); return; case GRPC_CHANNEL_FATAL_FAILURE: + case GRPC_CHANNEL_TRANSIENT_FAILURE: /* things have gone wrong, deactivate and enter idle */ if (sw->subchannel->active->refs == 0) { destroy_connection = sw->subchannel->active; @@ -444,15 +444,6 @@ static void on_state_changed(void *p, int iomgr_success) { grpc_connectivity_state_set(&c->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE); break; - case GRPC_CHANNEL_TRANSIENT_FAILURE: - /* things are starting to go wrong, reconnect but don't deactivate */ - /* released by connection */ - SUBCHANNEL_REF_LOCKED(c, "connecting"); - grpc_connectivity_state_set(&c->state_tracker, - GRPC_CHANNEL_TRANSIENT_FAILURE); - do_connect = 1; - c->connecting = 1; - break; } done: @@ -460,9 +451,6 @@ done: destroy = SUBCHANNEL_UNREF_LOCKED(c, "state_watcher"); gpr_free(sw); gpr_mu_unlock(mu); - if (do_connect) { - start_connect(c); - } if (destroy) { subchannel_destroy(c); } diff --git a/src/core/client_config/uri_parser.c b/src/core/client_config/uri_parser.c index 43b5b47f55e..c5faab5eba0 100644 --- a/src/core/client_config/uri_parser.c +++ b/src/core/client_config/uri_parser.c @@ -39,20 +39,22 @@ #include #include -static grpc_uri *bad_uri(const char *uri_text, int pos, const char *section) { +static grpc_uri *bad_uri(const char *uri_text, int pos, const char *section, int suppress_errors) { char *line_prefix; int pfx_len; - gpr_asprintf(&line_prefix, "bad uri.%s: '", section); - pfx_len = strlen(line_prefix) + pos; - gpr_log(GPR_ERROR, "%s%s'", line_prefix, uri_text); - gpr_free(line_prefix); + if (!suppress_errors) { + gpr_asprintf(&line_prefix, "bad uri.%s: '", section); + pfx_len = strlen(line_prefix) + pos; + gpr_log(GPR_ERROR, "%s%s'", line_prefix, uri_text); + gpr_free(line_prefix); - line_prefix = gpr_malloc(pfx_len + 1); - memset(line_prefix, ' ', pfx_len); - line_prefix[pfx_len] = 0; - gpr_log(GPR_ERROR, "%s^ here", line_prefix); - gpr_free(line_prefix); + line_prefix = gpr_malloc(pfx_len + 1); + memset(line_prefix, ' ', pfx_len); + line_prefix[pfx_len] = 0; + gpr_log(GPR_ERROR, "%s^ here", line_prefix); + gpr_free(line_prefix); + } return NULL; } @@ -64,7 +66,7 @@ static char *copy_fragment(const char *src, int begin, int end) { return out; } -grpc_uri *grpc_uri_parse(const char *uri_text) { +grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors) { grpc_uri *uri; int scheme_begin = 0; int scheme_end = -1; @@ -90,7 +92,7 @@ grpc_uri *grpc_uri_parse(const char *uri_text) { break; } if (scheme_end == -1) { - return bad_uri(uri_text, i, "scheme"); + return bad_uri(uri_text, i, "scheme", suppress_errors); } if (uri_text[scheme_end + 1] == '/' && uri_text[scheme_end + 2] == '/') { @@ -100,17 +102,17 @@ grpc_uri *grpc_uri_parse(const char *uri_text) { authority_end = i; } if (uri_text[i] == '?') { - return bad_uri(uri_text, i, "query_not_supported"); + return bad_uri(uri_text, i, "query_not_supported", suppress_errors); } if (uri_text[i] == '#') { - return bad_uri(uri_text, i, "fragment_not_supported"); + return bad_uri(uri_text, i, "fragment_not_supported", suppress_errors); } } if (authority_end == -1 && uri_text[i] == 0) { authority_end = i; } if (authority_end == -1) { - return bad_uri(uri_text, i, "authority"); + return bad_uri(uri_text, i, "authority", suppress_errors); } /* TODO(ctiller): parse the authority correctly */ path_begin = authority_end; @@ -120,10 +122,10 @@ grpc_uri *grpc_uri_parse(const char *uri_text) { for (i = path_begin; uri_text[i] != 0; i++) { if (uri_text[i] == '?') { - return bad_uri(uri_text, i, "query_not_supported"); + return bad_uri(uri_text, i, "query_not_supported", suppress_errors); } if (uri_text[i] == '#') { - return bad_uri(uri_text, i, "fragment_not_supported"); + return bad_uri(uri_text, i, "fragment_not_supported", suppress_errors); } } path_end = i; diff --git a/src/core/client_config/uri_parser.h b/src/core/client_config/uri_parser.h index b6821f9621e..ce4e6aecb09 100644 --- a/src/core/client_config/uri_parser.h +++ b/src/core/client_config/uri_parser.h @@ -41,7 +41,7 @@ typedef struct { } grpc_uri; /** parse a uri, return NULL on failure */ -grpc_uri *grpc_uri_parse(const char *uri_text); +grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors); /** destroy a uri */ void grpc_uri_destroy(grpc_uri *uri); diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 383c3d921dd..703eeaf2bd5 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -204,7 +204,9 @@ struct call_data { typedef struct { grpc_channel **channels; + grpc_channel **disconnects; size_t num_channels; + size_t num_disconnects; } channel_broadcaster; #define SERVER_FROM_CALL_ELEM(elem) \ @@ -223,18 +225,28 @@ static void maybe_finish_shutdown(grpc_server *server); static void channel_broadcaster_init(grpc_server *s, channel_broadcaster *cb) { channel_data *c; size_t count = 0; + size_t dc_count = 0; for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) { count ++; + if (c->num_calls == 0) { + dc_count ++; + } } cb->num_channels = count; + cb->num_disconnects = dc_count; cb->channels = gpr_malloc(sizeof(*cb->channels) * cb->num_channels); + cb->disconnects = gpr_malloc(sizeof(*cb->channels) * cb->num_disconnects); count = 0; + dc_count = 0; for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) { - cb->channels[count] = c->channel; + cb->channels[count++] = c->channel; GRPC_CHANNEL_INTERNAL_REF(c->channel, "broadcast"); - count ++; + if (c->num_calls == 0) { + cb->disconnects[dc_count++] = c->channel; + GRPC_CHANNEL_INTERNAL_REF(c->channel, "broadcast-disconnect"); + } } } @@ -274,10 +286,15 @@ static void channel_broadcaster_shutdown(channel_broadcaster *cb, int send_goawa size_t i; for (i = 0; i < cb->num_channels; i++) { - send_shutdown(cb->channels[i], send_goaway, send_disconnect); + send_shutdown(cb->channels[i], 1, 0); GRPC_CHANNEL_INTERNAL_UNREF(cb->channels[i], "broadcast"); } + for (i = 0; i < cb->num_disconnects; i++) { + send_shutdown(cb->disconnects[i], 0, 1); + GRPC_CHANNEL_INTERNAL_UNREF(cb->channels[i], "broadcast-disconnect"); + } gpr_free(cb->channels); + gpr_free(cb->disconnects); } /* call list */ diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 08a767f1d5b..e32071e6927 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -553,8 +553,7 @@ static void maybe_start_some_streams( transport_global->next_stream_id += 2; if (transport_global->next_stream_id >= MAX_CLIENT_STREAM_ID) { - connectivity_state_set(transport_global, - GRPC_CHANNEL_TRANSIENT_FAILURE); + connectivity_state_set(transport_global, GRPC_CHANNEL_TRANSIENT_FAILURE); } stream_global->outgoing_window = @@ -940,6 +939,7 @@ static void schedule_closure_for_connectivity(void *a, grpc_iomgr_closure *closu } static void connectivity_state_set(grpc_chttp2_transport_global *transport_global, grpc_connectivity_state state) { + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_DEBUG, "set connectivity_state=%d", state)); grpc_connectivity_state_set_with_scheduler( &TRANSPORT_FROM_GLOBAL(transport_global)->channel_callback.state_tracker, state, diff --git a/test/core/client_config/uri_parser_test.c b/test/core/client_config/uri_parser_test.c index 26566d09244..287a9d1addb 100644 --- a/test/core/client_config/uri_parser_test.c +++ b/test/core/client_config/uri_parser_test.c @@ -41,7 +41,7 @@ static void test_succeeds(const char *uri_text, const char *scheme, const char *authority, const char *path) { - grpc_uri *uri = grpc_uri_parse(uri_text); + grpc_uri *uri = grpc_uri_parse(uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp(scheme, uri->scheme)); GPR_ASSERT(0 == strcmp(authority, uri->authority)); @@ -50,7 +50,7 @@ static void test_succeeds(const char *uri_text, const char *scheme, } static void test_fails(const char *uri_text) { - GPR_ASSERT(NULL == grpc_uri_parse(uri_text)); + GPR_ASSERT(NULL == grpc_uri_parse(uri_text, 0)); } int main(int argc, char **argv) { From b49736829a3e9bf4140b17465ff6c208462e783f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 08:15:08 -0700 Subject: [PATCH 068/124] Fix pollset_set handling in tcp_client_posix --- src/core/iomgr/tcp_client_posix.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c index bbf7711588f..20f833e28b9 100644 --- a/src/core/iomgr/tcp_client_posix.c +++ b/src/core/iomgr/tcp_client_posix.c @@ -63,6 +63,7 @@ typedef struct { grpc_alarm alarm; int refs; grpc_iomgr_closure write_closure; + grpc_pollset_set *interested_parties; } async_connect; static int prepare_socket(const struct sockaddr *addr, int fd) { @@ -152,6 +153,7 @@ static void on_writable(void *acp, int success) { goto finish; } } else { + grpc_pollset_set_del_fd(ac->interested_parties, ac->fd); ep = grpc_tcp_create(ac->fd, GRPC_TCP_DEFAULT_READ_SLICE_SIZE); goto finish; } @@ -164,10 +166,13 @@ static void on_writable(void *acp, int success) { finish: gpr_mu_lock(&ac->mu); + gpr_log(GPR_DEBUG, "ep=%p", ep); if (!ep) { + grpc_pollset_set_del_fd(ac->interested_parties, ac->fd); grpc_fd_orphan(ac->fd, NULL, "tcp_client_orphan"); } done = (--ac->refs == 0); + gpr_log(GPR_DEBUG, "refs=%d", ac->refs); gpr_mu_unlock(&ac->mu); if (done) { gpr_mu_destroy(&ac->mu); @@ -240,6 +245,7 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep), ac->cb = cb; ac->cb_arg = arg; ac->fd = fdobj; + ac->interested_parties = interested_parties; gpr_mu_init(&ac->mu); ac->refs = 2; ac->write_closure.cb = on_writable; From 87cc0848ce279892cce562b3aa6cfae870d05e50 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 08:15:55 -0700 Subject: [PATCH 069/124] client_config bugfixes --- src/core/client_config/lb_policies/pick_first.c | 17 +++++++++++------ src/core/client_config/subchannel.c | 7 ++++++- src/core/client_config/subchannel.h | 2 -- src/core/iomgr/fd_posix.c | 3 ++- src/core/iomgr/iomgr.c | 8 +++++--- src/core/surface/channel_create.c | 1 + 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index a8e5b5cc4a5..ffdae75b283 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -176,15 +176,20 @@ loop: del_interested_parties_locked(p); GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel], p->subchannels[p->num_subchannels - 1]); - p->checking_subchannel %= p->num_subchannels; - p->checking_connectivity = grpc_subchannel_check_connectivity( - p->subchannels[p->checking_subchannel]); p->num_subchannels--; - GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); - add_interested_parties_locked(p); if (p->num_subchannels == 0) { - abort(); + while ((pp = p->pending_picks)) { + p->pending_picks = pp->next; + *pp->target = NULL; + grpc_iomgr_add_delayed_callback(pp->on_complete, 1); + gpr_free(pp); + } } else { + p->checking_subchannel %= p->num_subchannels; + p->checking_connectivity = grpc_subchannel_check_connectivity( + p->subchannels[p->checking_subchannel]); + GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); + add_interested_parties_locked(p); goto loop; } } diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index cae6db0110d..d16786a7ad2 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -546,6 +546,7 @@ static void on_alarm(void *arg, int iomgr_success) { grpc_subchannel *c = arg; gpr_mu_lock(&c->mu); c->have_alarm = 0; + connectivity_state_changed_locked(c); gpr_mu_unlock(&c->mu); if (iomgr_success) { continue_connect(c); @@ -560,6 +561,7 @@ static void subchannel_connected(void *arg, int iomgr_success) { publish_transport(c); } else { gpr_mu_lock(&c->mu); + connectivity_state_changed_locked(c); GPR_ASSERT(!c->have_alarm); c->have_alarm = 1; c->next_attempt = gpr_time_add(c->next_attempt, c->backoff_delta); @@ -570,7 +572,7 @@ static void subchannel_connected(void *arg, int iomgr_success) { } static gpr_timespec compute_connect_deadline(grpc_subchannel *c) { - return gpr_time_add(gpr_now(), gpr_time_from_seconds(60)); + return gpr_time_add(c->next_attempt, c->backoff_delta); } static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { @@ -578,6 +580,9 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { return GRPC_CHANNEL_FATAL_FAILURE; } if (c->connecting) { + if (c->have_alarm) { + return GRPC_CHANNEL_TRANSIENT_FAILURE; + } return GRPC_CHANNEL_CONNECTING; } if (c->active) { diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 03bd4f63e01..5435ef703b3 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -43,8 +43,6 @@ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; -#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG - #ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG #define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p), __FILE__, __LINE__, (r)) #define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p), __FILE__, __LINE__, (r)) diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index d12974cf3ce..446081954db 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -115,7 +115,7 @@ static void destroy(grpc_fd *fd) { #define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__) static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file, int line) { - gpr_log(GPR_DEBUG, "FD %d %p ref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n, + gpr_log(GPR_DEBUG, "FD %d %p ref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst), gpr_atm_no_barrier_load(&fd->refst) + n, reason, file, line); #else @@ -159,6 +159,7 @@ void grpc_fd_global_shutdown(void) { grpc_fd *grpc_fd_create(int fd, const char *name) { grpc_fd *r = alloc_fd(fd); + gpr_log(GPR_DEBUG, "FD %d %p create", r->fd, r); grpc_iomgr_register_object(&r->iomgr_object, name); return r; } diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c index 8fbddd73b0f..e4006013110 100644 --- a/src/core/iomgr/iomgr.c +++ b/src/core/iomgr/iomgr.c @@ -158,7 +158,7 @@ void grpc_iomgr_shutdown(void) { "memory leaks are likely", count_objects()); for (obj = g_root_object.next; obj != &g_root_object; obj = obj->next) { - gpr_log(GPR_DEBUG, "LEAKED OBJECT: %s", obj->name); + gpr_log(GPR_DEBUG, "LEAKED OBJECT: %s %p", obj->name, obj); } break; } @@ -177,8 +177,9 @@ void grpc_iomgr_shutdown(void) { } void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name) { - gpr_mu_lock(&g_mu); obj->name = gpr_strdup(name); + gpr_log(GPR_DEBUG, "register: %s %p", obj->name, obj); + gpr_mu_lock(&g_mu); obj->next = &g_root_object; obj->prev = obj->next->prev; obj->next->prev = obj->prev->next = obj; @@ -186,12 +187,13 @@ void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name) { } void grpc_iomgr_unregister_object(grpc_iomgr_object *obj) { + gpr_log(GPR_DEBUG, "unregister: %s %p", obj->name, obj); gpr_mu_lock(&g_mu); obj->next->prev = obj->prev; obj->prev->next = obj->next; - gpr_free(obj->name); gpr_cv_signal(&g_rcv); gpr_mu_unlock(&g_mu); + gpr_free(obj->name); } void grpc_iomgr_closure_init(grpc_iomgr_closure *closure, grpc_iomgr_cb_func cb, diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 6b559e1fb42..20da8303881 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -73,6 +73,7 @@ static void connected(void *arg, grpc_endpoint *tcp) { if (tcp != NULL) { c->result->transport = grpc_create_chttp2_transport(c->args.channel_args, tcp, NULL, 0, c->args.metadata_context, 1); + GPR_ASSERT(c->result->transport); c->result->filters = gpr_malloc(sizeof(grpc_channel_filter*)); c->result->filters[0] = &grpc_http_client_filter; c->result->num_filters = 1; From 52f842fb73c3a1e99101026b19cb4be98dfa73bd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 09:31:12 -0700 Subject: [PATCH 070/124] Spam cleanup --- src/core/iomgr/iomgr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c index e4006013110..c507e7c26a7 100644 --- a/src/core/iomgr/iomgr.c +++ b/src/core/iomgr/iomgr.c @@ -178,7 +178,6 @@ void grpc_iomgr_shutdown(void) { void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name) { obj->name = gpr_strdup(name); - gpr_log(GPR_DEBUG, "register: %s %p", obj->name, obj); gpr_mu_lock(&g_mu); obj->next = &g_root_object; obj->prev = obj->next->prev; @@ -187,7 +186,6 @@ void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name) { } void grpc_iomgr_unregister_object(grpc_iomgr_object *obj) { - gpr_log(GPR_DEBUG, "unregister: %s %p", obj->name, obj); gpr_mu_lock(&g_mu); obj->next->prev = obj->prev; obj->prev->next = obj->next; From 974472464ce6c4eb554263c00bc81eeab36d4078 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 09:31:26 -0700 Subject: [PATCH 071/124] Fix memory corruption bug --- src/core/iomgr/pollset_set_posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/iomgr/pollset_set_posix.c b/src/core/iomgr/pollset_set_posix.c index 005e9383982..5ff7df1dcd2 100644 --- a/src/core/iomgr/pollset_set_posix.c +++ b/src/core/iomgr/pollset_set_posix.c @@ -114,7 +114,7 @@ void grpc_pollset_set_del_fd(grpc_pollset_set *pollset_set, grpc_fd *fd) { if (pollset_set->fds[i] == fd) { pollset_set->fd_count--; GPR_SWAP(grpc_fd *, pollset_set->fds[i], - pollset_set->fds[pollset_set->pollset_count]); + pollset_set->fds[pollset_set->fd_count]); GRPC_FD_UNREF(fd, "pollset_set"); break; } From bb32ba32ce5f0606b6e9f3d5ea092b4c89e2ef6e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 09:31:48 -0700 Subject: [PATCH 072/124] Fix use-after-free --- src/core/channel/client_channel.c | 48 ++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index e62a262babd..2b6f162072c 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -237,6 +237,32 @@ static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { initial_metadata, &calld->picked_channel, &calld->async_setup_task); } +static void merge_into_waiting_op(grpc_call_element *elem, grpc_transport_stream_op *new_op) { + call_data *calld = elem->call_data; + grpc_transport_stream_op *waiting_op = &calld->waiting_op; + GPR_ASSERT((waiting_op->send_ops == NULL) != + (new_op->send_ops == NULL)); + GPR_ASSERT((waiting_op->recv_ops == NULL) != + (new_op->recv_ops == NULL)); + if (new_op->send_ops != NULL) { + waiting_op->send_ops = new_op->send_ops; + waiting_op->is_last_send = new_op->is_last_send; + waiting_op->on_done_send = new_op->on_done_send; + } + if (new_op->recv_ops != NULL) { + waiting_op->recv_ops = new_op->recv_ops; + waiting_op->recv_state = new_op->recv_state; + waiting_op->on_done_recv = new_op->on_done_recv; + } + if (waiting_op->on_consumed == NULL) { + waiting_op->on_consumed = new_op->on_consumed; + new_op->on_consumed = NULL; + } + if (new_op->cancel_with_status != GRPC_STATUS_OK) { + waiting_op->cancel_with_status = new_op->cancel_with_status; + } +} + static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_stream_op *op, int continuation) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; @@ -266,24 +292,18 @@ static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_ calld->state = CALL_CANCELLED; op2 = calld->waiting_op; memset(&calld->waiting_op, 0, sizeof(calld->waiting_op)); + if (op->on_consumed) { + calld->waiting_op.on_consumed = op->on_consumed; + op->on_consumed = NULL; + } else if (op2.on_consumed) { + calld->waiting_op.on_consumed = op2.on_consumed; + op2.on_consumed = NULL; + } gpr_mu_unlock(&calld->mu_state); handle_op_after_cancellation(elem, op); handle_op_after_cancellation(elem, &op2); } else { - GPR_ASSERT((calld->waiting_op.send_ops == NULL) != - (op->send_ops == NULL)); - GPR_ASSERT((calld->waiting_op.recv_ops == NULL) != - (op->recv_ops == NULL)); - if (op->send_ops != NULL) { - calld->waiting_op.send_ops = op->send_ops; - calld->waiting_op.is_last_send = op->is_last_send; - calld->waiting_op.on_done_send = op->on_done_send; - } - if (op->recv_ops != NULL) { - calld->waiting_op.recv_ops = op->recv_ops; - calld->waiting_op.recv_state = op->recv_state; - calld->waiting_op.on_done_recv = op->on_done_recv; - } + merge_into_waiting_op(elem, op); gpr_mu_unlock(&calld->mu_state); if (op->on_consumed != NULL) { op->on_consumed->cb(op->on_consumed->cb_arg, 0); From 614e27a10acb4d95a716da86c0a3c673d3b52957 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 09:32:17 -0700 Subject: [PATCH 073/124] Fix refcounting --- src/core/surface/secure_channel_create.c | 158 +---------------------- 1 file changed, 2 insertions(+), 156 deletions(-) diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index b60f390370b..d3550792609 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -164,151 +164,6 @@ static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_fac static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchannel_factory_ref, subchannel_factory_unref, subchannel_factory_create_subchannel}; -#if 0 -typedef struct setup setup; - -/* A single setup request (started via initiate) */ -typedef struct { - grpc_client_setup_request *cs_request; - setup *setup; - /* Resolved addresses, or null if resolution not yet completed. */ - grpc_resolved_addresses *resolved; - /* which address in resolved should we pick for the next connection attempt */ - size_t resolved_index; -} request; - -struct setup { - grpc_channel_security_connector *security_connector; - const char *target; - grpc_transport_setup_callback setup_callback; - void *setup_user_data; -}; - -static int maybe_try_next_resolved(request *r); - -static void done(request *r, int was_successful) { - grpc_client_setup_request_finish(r->cs_request, was_successful); - if (r->resolved) { - grpc_resolved_addresses_destroy(r->resolved); - } - gpr_free(r); -} - -static void on_secure_transport_setup_done(void *rp, - grpc_security_status status, - grpc_endpoint *secure_endpoint) { - request *r = rp; - if (status != GRPC_SECURITY_OK) { - gpr_log(GPR_ERROR, "Secure transport setup failed with error %d.", status); - done(r, 0); - } else if (grpc_client_setup_cb_begin(r->cs_request, - "on_secure_transport_setup_done")) { - grpc_create_chttp2_transport( - r->setup->setup_callback, r->setup->setup_user_data, - grpc_client_setup_get_channel_args(r->cs_request), secure_endpoint, - NULL, 0, grpc_client_setup_get_mdctx(r->cs_request), 1); - grpc_client_setup_cb_end(r->cs_request, "on_secure_transport_setup_done"); - done(r, 1); - } else { - done(r, 0); - } -} - -/* connection callback: tcp is either valid, or null on error */ -static void on_connect(void *rp, grpc_endpoint *tcp) { - request *r = rp; - - if (!grpc_client_setup_request_should_continue(r->cs_request, - "on_connect.secure")) { - if (tcp) { - grpc_endpoint_shutdown(tcp); - grpc_endpoint_destroy(tcp); - } - done(r, 0); - return; - } - - if (!tcp) { - if (!maybe_try_next_resolved(r)) { - done(r, 0); - return; - } else { - return; - } - } else { - grpc_setup_secure_transport(&r->setup->security_connector->base, tcp, - on_secure_transport_setup_done, r); - } -} - -/* attempt to connect to the next available resolved address */ -static int maybe_try_next_resolved(request *r) { - grpc_resolved_address *addr; - if (!r->resolved) return 0; - if (r->resolved_index == r->resolved->naddrs) return 0; - addr = &r->resolved->addrs[r->resolved_index++]; - grpc_tcp_client_connect( - on_connect, r, grpc_client_setup_get_interested_parties(r->cs_request), - (struct sockaddr *)&addr->addr, addr->len, - grpc_client_setup_request_deadline(r->cs_request)); - return 1; -} - -/* callback for when our target address has been resolved */ -static void on_resolved(void *rp, grpc_resolved_addresses *resolved) { - request *r = rp; - - /* if we're not still the active request, abort */ - if (!grpc_client_setup_request_should_continue(r->cs_request, - "on_resolved.secure")) { - if (resolved) { - grpc_resolved_addresses_destroy(resolved); - } - done(r, 0); - return; - } - - if (!resolved) { - done(r, 0); - return; - } else { - r->resolved = resolved; - r->resolved_index = 0; - if (!maybe_try_next_resolved(r)) { - done(r, 0); - } - } -} - -static void initiate_setup(void *sp, grpc_client_setup_request *cs_request) { - request *r = gpr_malloc(sizeof(request)); - r->setup = sp; - r->cs_request = cs_request; - r->resolved = NULL; - r->resolved_index = 0; - /* TODO(klempner): Make grpc_resolve_address respect deadline */ - grpc_resolve_address(r->setup->target, "https", on_resolved, r); -} - -static void done_setup(void *sp) { - setup *s = sp; - gpr_free((void *)s->target); - grpc_security_connector_unref(&s->security_connector->base); - gpr_free(s); -} - -static grpc_transport_setup_result complete_setup(void *channel_stack, - grpc_transport *transport, - grpc_mdctx *mdctx) { - static grpc_channel_filter const *extra_filters[] = { - &grpc_client_auth_filter, &grpc_http_client_filter}; - return grpc_client_channel_transport_setup_complete( - channel_stack, transport, extra_filters, GPR_ARRAY_SIZE(extra_filters), - mdctx); -} - -#endif - /* Create a secure client channel: Asynchronously: - resolve target - connect to it (trying alternatives as presented) @@ -354,6 +209,7 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, f = gpr_malloc(sizeof(*f)); f->base.vtable = &subchannel_factory_vtable; gpr_ref_init(&f->refs, 1); + grpc_mdctx_ref(mdctx); f->mdctx = mdctx; f->security_connector = connector; f->merge_args = grpc_channel_args_copy(args_copy); @@ -364,22 +220,12 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, channel = grpc_channel_create_from_filters(filters, n, args_copy, mdctx, 1); grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); - grpc_resolver_unref(resolver); + GRPC_RESOLVER_UNREF(resolver, "create"); grpc_channel_args_destroy(args_copy); if (new_args_from_connector != NULL) { grpc_channel_args_destroy(new_args_from_connector); } -#if 0 - s->target = gpr_strdup(target); - s->setup_callback = complete_setup; - s->setup_user_data = grpc_channel_get_channel_stack(channel); - s->security_connector = connector; - grpc_client_setup_create_and_attach(grpc_channel_get_channel_stack(channel), - args, mdctx, initiate_setup, done_setup, - s); -#endif - return channel; } From d1d0c0a876fa22cf47700173aa6c68278e2ff662 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 09:47:25 -0700 Subject: [PATCH 074/124] Fix a bug where we can spuriously wakeup a nonexistant fd --- src/core/iomgr/pollset_multipoller_with_poll_posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c index cc062693a96..7b717bd1593 100644 --- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c +++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c @@ -179,6 +179,9 @@ static void multipoll_with_poll_pollset_maybe_work( grpc_pollset_kick_consume(&pollset->kick_state, kfd); } for (i = 1; i < np; i++) { + if (h->watchers[i].fd == NULL) { + continue; + } if (h->pfds[i].revents & (POLLIN | POLLHUP | POLLERR)) { grpc_fd_become_readable(h->watchers[i].fd, allow_synchronous_callback); } From 6fa9148d51a5b4a9b6fb8502191b2aac87e0d57b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 10:05:03 -0700 Subject: [PATCH 075/124] Spam cleanup --- src/core/channel/client_channel.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 2b6f162072c..cb36fdc0295 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -476,7 +476,6 @@ static void destroy_call_elem(grpc_call_element *elem) { remove it from the in-flight requests tracked by the child_entry we picked */ gpr_mu_lock(&calld->mu_state); - gpr_log(GPR_DEBUG, "call_elem destroy @ state %d", calld->state); switch (calld->state) { case CALL_ACTIVE: subchannel_call = calld->subchannel_call; From 079a11bb9b253e91c89e625950ea09879d2d6f8e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 10:07:15 -0700 Subject: [PATCH 076/124] clang-format affected files --- include/grpc/grpc.h | 4 +- src/core/channel/census_filter.c | 24 +++++-- src/core/channel/channel_args.c | 4 +- src/core/channel/channel_args.h | 9 +-- src/core/channel/channel_stack.c | 8 ++- src/core/channel/channel_stack.h | 8 +-- src/core/channel/client_channel.c | 67 ++++++++++++------- src/core/channel/client_channel.h | 2 +- src/core/channel/connected_channel.c | 2 +- src/core/channel/connected_channel.h | 2 +- src/core/channel/http_client_filter.c | 2 +- src/core/channel/http_server_filter.c | 2 +- src/core/channel/noop_filter.c | 2 +- src/core/client_config/resolver.c | 12 ++-- src/core/client_config/resolver.h | 9 ++- .../resolvers/unix_resolver_posix.c | 2 +- src/core/client_config/subchannel.c | 58 ++++++++++------ src/core/client_config/subchannel.h | 27 +++++--- src/core/client_config/uri_parser.c | 3 +- src/core/iomgr/fd_posix.c | 3 +- src/core/security/client_auth_filter.c | 4 +- src/core/security/server_auth_filter.c | 9 ++- src/core/security/server_secure_chttp2.c | 12 ++-- src/core/surface/call.c | 17 ++--- src/core/surface/channel.c | 4 +- src/core/surface/channel_create.c | 29 +++++--- src/core/surface/lame_client.c | 2 +- src/core/surface/secure_channel_create.c | 29 +++++--- src/core/surface/server.c | 23 +++---- src/core/transport/chttp2_transport.c | 58 ++++++++-------- src/core/transport/connectivity_state.c | 6 +- src/core/transport/connectivity_state.h | 3 +- src/core/transport/transport.c | 5 +- src/core/transport/transport.h | 11 +-- src/core/transport/transport_impl.h | 2 +- test/core/bad_client/bad_client.c | 11 ++- test/core/channel/channel_stack_test.c | 7 +- .../end2end/fixtures/chttp2_socket_pair.c | 24 +++---- .../chttp2_socket_pair_one_byte_at_a_time.c | 24 +++---- .../chttp2_socket_pair_with_grpc_trace.c | 24 +++---- .../end2end/multiple_server_queues_test.c | 2 +- test/core/iomgr/fd_conservation_posix_test.c | 12 ++-- 42 files changed, 325 insertions(+), 243 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 147343049b5..782923d599e 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -441,7 +441,7 @@ void grpc_channel_destroy(grpc_channel *channel); has been made. */ /* 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. THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status are thread-safe, and can be called at any point before grpc_call_destroy is called.*/ @@ -457,7 +457,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *call, grpc_status_code status, const char *description); -/* Destroy a call. +/* Destroy a call. THREAD SAFETY: grpc_call_destroy is thread-compatible */ void grpc_call_destroy(grpc_call *call); diff --git a/src/core/channel/census_filter.c b/src/core/channel/census_filter.c index ea0bece587e..83b76828481 100644 --- a/src/core/channel/census_filter.c +++ b/src/core/channel/census_filter.c @@ -202,11 +202,23 @@ static void destroy_channel_elem(grpc_channel_element* elem) { } const grpc_channel_filter grpc_client_census_filter = { - client_start_transport_op, channel_op, sizeof(call_data), - client_init_call_elem, client_destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "census-client"}; + client_start_transport_op, + channel_op, + sizeof(call_data), + client_init_call_elem, + client_destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + "census-client"}; const grpc_channel_filter grpc_server_census_filter = { - server_start_transport_op, channel_op, sizeof(call_data), - server_init_call_elem, server_destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "census-server"}; + server_start_transport_op, + channel_op, + sizeof(call_data), + server_init_call_elem, + server_destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + "census-server"}; diff --git a/src/core/channel/channel_args.c b/src/core/channel/channel_args.c index 371da4210ee..140f8bd6563 100644 --- a/src/core/channel/channel_args.c +++ b/src/core/channel/channel_args.c @@ -139,8 +139,8 @@ grpc_compression_level grpc_channel_args_get_compression_level( return GRPC_COMPRESS_LEVEL_NONE; } -void grpc_channel_args_set_compression_level( - grpc_channel_args **a, grpc_compression_level level) { +void grpc_channel_args_set_compression_level(grpc_channel_args **a, + grpc_compression_level level) { grpc_arg tmp; tmp.type = GRPC_ARG_INTEGER; tmp.key = GRPC_COMPRESSION_LEVEL_ARG; diff --git a/src/core/channel/channel_args.h b/src/core/channel/channel_args.h index 27ad57b3e8f..17849b7e59d 100644 --- a/src/core/channel/channel_args.h +++ b/src/core/channel/channel_args.h @@ -47,7 +47,8 @@ grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src, size_t num_to_add); /** Copy args from a then args from b into a new channel args */ -grpc_channel_args *grpc_channel_args_merge(const grpc_channel_args *a, const grpc_channel_args *b); +grpc_channel_args *grpc_channel_args_merge(const grpc_channel_args *a, + const grpc_channel_args *b); /** Destroy arguments created by grpc_channel_args_copy */ void grpc_channel_args_destroy(grpc_channel_args *a); @@ -62,7 +63,7 @@ grpc_compression_level grpc_channel_args_get_compression_level( /** Sets the compression level in \a a to \a level. Setting it to * GRPC_COMPRESS_LEVEL_NONE disables compression for the channel. */ -void grpc_channel_args_set_compression_level( - grpc_channel_args **a, grpc_compression_level level); +void grpc_channel_args_set_compression_level(grpc_channel_args **a, + grpc_compression_level level); -#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H */ diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c index 0810a61cd0a..e38dcb58b78 100644 --- a/src/core/channel/channel_stack.c +++ b/src/core/channel/channel_stack.c @@ -102,7 +102,8 @@ grpc_call_element *grpc_call_stack_element(grpc_call_stack *call_stack, } void grpc_channel_stack_init(const grpc_channel_filter **filters, - size_t filter_count, grpc_channel *master, const grpc_channel_args *args, + size_t filter_count, grpc_channel *master, + const grpc_channel_args *args, grpc_mdctx *metadata_context, grpc_channel_stack *stack) { size_t call_size = @@ -122,8 +123,9 @@ void grpc_channel_stack_init(const grpc_channel_filter **filters, for (i = 0; i < filter_count; i++) { elems[i].filter = filters[i]; elems[i].channel_data = user_data; - elems[i].filter->init_channel_elem(&elems[i], master, args, metadata_context, - i == 0, i == (filter_count - 1)); + elems[i].filter->init_channel_elem(&elems[i], master, args, + metadata_context, i == 0, + i == (filter_count - 1)); user_data += ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_channel_data); call_size += ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_call_data); } diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h index 6db98815df7..785be8925ba 100644 --- a/src/core/channel/channel_stack.h +++ b/src/core/channel/channel_stack.h @@ -65,7 +65,7 @@ typedef struct { /* Called to eg. send/receive data on a call. See grpc_call_next_op on how to call the next element in the stack */ void (*start_transport_stream_op)(grpc_call_element *elem, - grpc_transport_stream_op *op); + grpc_transport_stream_op *op); /* Called to handle channel level operations - e.g. new calls, or transport closure. See grpc_channel_next_op on how to call the next element in the stack */ @@ -96,8 +96,7 @@ typedef struct { is_first, is_last designate this elements position in the stack, and are useful for asserting correct configuration by upper layer code. The filter does not need to do any chaining */ - void (*init_channel_elem)(grpc_channel_element *elem, - grpc_channel *master, + void (*init_channel_elem)(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last); @@ -152,7 +151,8 @@ size_t grpc_channel_stack_size(const grpc_channel_filter **filters, size_t filter_count); /* Initialize a channel stack given some filters */ void grpc_channel_stack_init(const grpc_channel_filter **filters, - size_t filter_count, grpc_channel *master,const grpc_channel_args *args, + size_t filter_count, grpc_channel *master, + const grpc_channel_args *args, grpc_mdctx *metadata_context, grpc_channel_stack *stack); /* Destroy a channel stack */ diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index cb36fdc0295..6815ec8718e 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -138,7 +138,9 @@ typedef struct { grpc_call_element *elem; } waiting_call; -static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_stream_op *op, int continuation); +static void perform_transport_stream_op(grpc_call_element *elem, + grpc_transport_stream_op *op, + int continuation); static void continue_with_pick(void *arg, int iomgr_success) { waiting_call *wc = arg; @@ -147,7 +149,8 @@ static void continue_with_pick(void *arg, int iomgr_success) { gpr_free(wc); } -static void add_to_lb_policy_wait_queue_locked_state_config(grpc_call_element *elem) { +static void add_to_lb_policy_wait_queue_locked_state_config( + grpc_call_element *elem) { channel_data *chand = elem->channel_data; waiting_call *wc = gpr_malloc(sizeof(*wc)); grpc_iomgr_closure_init(&wc->closure, continue_with_pick, wc); @@ -182,7 +185,8 @@ static void started_call(void *arg, int iomgr_success) { calld->state = CALL_ACTIVE; gpr_mu_unlock(&calld->mu_state); if (have_waiting) { - grpc_subchannel_call_process_op(calld->subchannel_call, &calld->waiting_op); + grpc_subchannel_call_process_op(calld->subchannel_call, + &calld->waiting_op); } } else { calld->state = CALL_CANCELLED; @@ -233,17 +237,16 @@ static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { initial_metadata = &op->send_ops->ops[0].data.metadata; grpc_iomgr_closure_init(&calld->async_setup_task, picked_target, calld); - grpc_lb_policy_pick(lb_policy, op->bind_pollset, - initial_metadata, &calld->picked_channel, &calld->async_setup_task); + grpc_lb_policy_pick(lb_policy, op->bind_pollset, initial_metadata, + &calld->picked_channel, &calld->async_setup_task); } -static void merge_into_waiting_op(grpc_call_element *elem, grpc_transport_stream_op *new_op) { +static void merge_into_waiting_op(grpc_call_element *elem, + grpc_transport_stream_op *new_op) { call_data *calld = elem->call_data; grpc_transport_stream_op *waiting_op = &calld->waiting_op; - GPR_ASSERT((waiting_op->send_ops == NULL) != - (new_op->send_ops == NULL)); - GPR_ASSERT((waiting_op->recv_ops == NULL) != - (new_op->recv_ops == NULL)); + GPR_ASSERT((waiting_op->send_ops == NULL) != (new_op->send_ops == NULL)); + GPR_ASSERT((waiting_op->recv_ops == NULL) != (new_op->recv_ops == NULL)); if (new_op->send_ops != NULL) { waiting_op->send_ops = new_op->send_ops; waiting_op->is_last_send = new_op->is_last_send; @@ -263,7 +266,9 @@ static void merge_into_waiting_op(grpc_call_element *elem, grpc_transport_stream } } -static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_stream_op *op, int continuation) { +static void perform_transport_stream_op(grpc_call_element *elem, + grpc_transport_stream_op *op, + int continuation) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; grpc_subchannel_call *subchannel_call; @@ -311,7 +316,7 @@ static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_ } break; } - /* fall through */ + /* fall through */ case CALL_CREATED: if (op->cancel_with_status != GRPC_STATUS_OK) { calld->state = CALL_CANCELLED; @@ -343,7 +348,7 @@ static void perform_transport_stream_op(grpc_call_element *elem, grpc_transport_ } static void cc_start_transport_stream_op(grpc_call_element *elem, - grpc_transport_stream_op *op) { + grpc_transport_stream_op *op) { perform_transport_stream_op(elem, op, 0); } @@ -382,12 +387,14 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { GRPC_RESOLVER_REF(resolver, "channel-next"); gpr_mu_unlock(&chand->mu_config); GRPC_CHANNEL_INTERNAL_REF(chand->master, "resolver"); - grpc_resolver_next(chand->resolver, &chand->incoming_configuration, &chand->on_config_changed); + grpc_resolver_next(chand->resolver, &chand->incoming_configuration, + &chand->on_config_changed); GRPC_RESOLVER_UNREF(resolver, "channel-next"); } else { old_resolver = chand->resolver; chand->resolver = NULL; - grpc_connectivity_state_set(&chand->state_tracker, GRPC_CHANNEL_FATAL_FAILURE); + grpc_connectivity_state_set(&chand->state_tracker, + GRPC_CHANNEL_FATAL_FAILURE); gpr_mu_unlock(&chand->mu_config); if (old_resolver != NULL) { grpc_resolver_shutdown(old_resolver); @@ -404,7 +411,8 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { GRPC_CHANNEL_INTERNAL_UNREF(chand->master, "resolver"); } -static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op *op) { +static void cc_start_transport_op(grpc_channel_element *elem, + grpc_transport_op *op) { grpc_lb_policy *lb_policy = NULL; channel_data *chand = elem->channel_data; grpc_resolver *destroy_resolver = NULL; @@ -416,13 +424,16 @@ static void cc_start_transport_op(grpc_channel_element *elem, grpc_transport_op gpr_mu_lock(&chand->mu_config); if (op->on_connectivity_state_change != NULL) { - grpc_connectivity_state_notify_on_state_change(&chand->state_tracker, op->connectivity_state, op->on_connectivity_state_change); + grpc_connectivity_state_notify_on_state_change( + &chand->state_tracker, op->connectivity_state, + op->on_connectivity_state_change); op->on_connectivity_state_change = NULL; op->connectivity_state = NULL; } if (op->disconnect && chand->resolver != NULL) { - grpc_connectivity_state_set(&chand->state_tracker, GRPC_CHANNEL_FATAL_FAILURE); + grpc_connectivity_state_set(&chand->state_tracker, + GRPC_CHANNEL_FATAL_FAILURE); destroy_resolver = chand->resolver; chand->resolver = NULL; } @@ -496,7 +507,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { @@ -510,7 +521,8 @@ static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, gpr_mu_init(&chand->mu_config); chand->mdctx = metadata_context; chand->master = master; - grpc_iomgr_closure_init(&chand->on_config_changed, cc_on_config_changed, chand); + grpc_iomgr_closure_init(&chand->on_config_changed, cc_on_config_changed, + chand); grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE); } @@ -530,9 +542,15 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_client_channel_filter = { - cc_start_transport_stream_op, cc_start_transport_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "client-channel", + cc_start_transport_stream_op, + cc_start_transport_op, + sizeof(call_data), + init_call_elem, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + "client-channel", }; void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, @@ -544,5 +562,6 @@ void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, chand->resolver = resolver; GRPC_CHANNEL_INTERNAL_REF(chand->master, "resolver"); GRPC_RESOLVER_REF(resolver, "channel"); - grpc_resolver_next(resolver, &chand->incoming_configuration, &chand->on_config_changed); + grpc_resolver_next(resolver, &chand->incoming_configuration, + &chand->on_config_changed); } diff --git a/src/core/channel/client_channel.h b/src/core/channel/client_channel.h index 5ab64b9c46b..fd2be46145f 100644 --- a/src/core/channel/client_channel.h +++ b/src/core/channel/client_channel.h @@ -52,4 +52,4 @@ extern const grpc_channel_filter grpc_client_channel_filter; void grpc_client_channel_set_resolver(grpc_channel_stack *channel_stack, grpc_resolver *resolver); -#endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H */ diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 99c8a643f62..34d07de5196 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -103,7 +103,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { channel_data *cd = (channel_data *)elem->channel_data; diff --git a/src/core/channel/connected_channel.h b/src/core/channel/connected_channel.h index d1e2c195cb7..b615b0d3509 100644 --- a/src/core/channel/connected_channel.h +++ b/src/core/channel/connected_channel.h @@ -46,4 +46,4 @@ extern const grpc_channel_filter grpc_connected_channel_filter; void grpc_connected_channel_bind_transport(grpc_channel_stack *channel_stack, grpc_transport *transport); -#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H */ diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index 3d1fc6a0204..581eb13f581 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -170,7 +170,7 @@ static const char *scheme_from_args(const grpc_channel_args *args) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { /* grab pointers to our data from the channel element */ diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c index 3b1128bef9d..db0bf590c6e 100644 --- a/src/core/channel/http_server_filter.c +++ b/src/core/channel/http_server_filter.c @@ -229,7 +229,7 @@ static void init_call_elem(grpc_call_element *elem, static void destroy_call_elem(grpc_call_element *elem) {} /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { /* grab pointers to our data from the channel element */ diff --git a/src/core/channel/noop_filter.c b/src/core/channel/noop_filter.c index 0d9c2e82a82..51177236179 100644 --- a/src/core/channel/noop_filter.c +++ b/src/core/channel/noop_filter.c @@ -95,7 +95,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { /* grab pointers to our data from the channel element */ diff --git a/src/core/client_config/resolver.c b/src/core/client_config/resolver.c index bbc0ec4e819..91e42bb6844 100644 --- a/src/core/client_config/resolver.c +++ b/src/core/client_config/resolver.c @@ -34,16 +34,17 @@ #include "src/core/client_config/resolver.h" void grpc_resolver_init(grpc_resolver *resolver, - const grpc_resolver_vtable *vtable) { + const grpc_resolver_vtable *vtable) { resolver->vtable = vtable; gpr_ref_init(&resolver->refs, 1); } #ifdef GRPC_RESOLVER_REFCOUNT_DEBUG void grpc_resolver_ref(grpc_resolver *resolver, const char *file, int line, - const char *reason) { + const char *reason) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "RESOLVER:%p ref %d -> %d %s", - resolver, (int)resolver->refs.count, (int)resolver->refs.count + 1, reason); + resolver, (int)resolver->refs.count, (int)resolver->refs.count + 1, + reason); #else void grpc_resolver_ref(grpc_resolver *resolver) { #endif @@ -52,9 +53,10 @@ void grpc_resolver_ref(grpc_resolver *resolver) { #ifdef GRPC_RESOLVER_REFCOUNT_DEBUG void grpc_resolver_unref(grpc_resolver *resolver, const char *file, int line, - const char *reason) { + const char *reason) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "RESOLVER:%p unref %d -> %d %s", - resolver, (int)resolver->refs.count, (int)resolver->refs.count - 1, reason); + resolver, (int)resolver->refs.count, (int)resolver->refs.count - 1, + reason); #else void grpc_resolver_unref(grpc_resolver *resolver) { #endif diff --git a/src/core/client_config/resolver.h b/src/core/client_config/resolver.h index 16b5964eb6e..8ad87d789b5 100644 --- a/src/core/client_config/resolver.h +++ b/src/core/client_config/resolver.h @@ -59,14 +59,13 @@ struct grpc_resolver_vtable { }; #ifdef GRPC_RESOLVER_REFCOUNT_DEBUG -#define GRPC_RESOLVER_REF(p, r) \ - grpc_resolver_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p), __FILE__, __LINE__, (r)) #define GRPC_RESOLVER_UNREF(p, r) \ grpc_resolver_unref((p), __FILE__, __LINE__, (r)) void grpc_resolver_ref(grpc_resolver *policy, const char *file, int line, - const char *reason); + const char *reason); void grpc_resolver_unref(grpc_resolver *policy, const char *file, int line, - const char *reason); + const char *reason); #else #define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p)) #define GRPC_RESOLVER_UNREF(p, r) grpc_resolver_unref((p)) @@ -75,7 +74,7 @@ void grpc_resolver_unref(grpc_resolver *policy); #endif void grpc_resolver_init(grpc_resolver *resolver, - const grpc_resolver_vtable *vtable); + const grpc_resolver_vtable *vtable); void grpc_resolver_shutdown(grpc_resolver *resolver); diff --git a/src/core/client_config/resolvers/unix_resolver_posix.c b/src/core/client_config/resolvers/unix_resolver_posix.c index 7f2008685c7..be515d26897 100644 --- a/src/core/client_config/resolvers/unix_resolver_posix.c +++ b/src/core/client_config/resolvers/unix_resolver_posix.c @@ -136,7 +136,7 @@ static void unix_maybe_finish_next_locked(unix_resolver *r) { } static void unix_destroy(grpc_resolver *gr) { - unix_resolver *r = (unix_resolver*)gr; + unix_resolver *r = (unix_resolver *)gr; gpr_mu_destroy(&r->mu); grpc_subchannel_factory_unref(r->subchannel_factory); gpr_free(r); diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index d16786a7ad2..cde14b92223 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -134,21 +134,31 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c); static gpr_timespec compute_connect_deadline(grpc_subchannel *c); static void subchannel_connected(void *subchannel, int iomgr_success); -static void subchannel_ref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS); -static int subchannel_unref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) GRPC_MUST_USE_RESULT; +static void subchannel_ref_locked( + grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +static int subchannel_unref_locked( + grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) GRPC_MUST_USE_RESULT; static void connection_ref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS); -static grpc_subchannel *connection_unref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) - GRPC_MUST_USE_RESULT; +static grpc_subchannel *connection_unref_locked( + connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) GRPC_MUST_USE_RESULT; static void subchannel_destroy(grpc_subchannel *c); #ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -#define SUBCHANNEL_REF_LOCKED(p, r) subchannel_ref_locked((p), __FILE__, __LINE__, (r)) -#define SUBCHANNEL_UNREF_LOCKED(p, r) subchannel_unref_locked((p), __FILE__, __LINE__, (r)) -#define CONNECTION_REF_LOCKED(p, r) connection_ref_locked((p), __FILE__, __LINE__, (r)) -#define CONNECTION_UNREF_LOCKED(p, r) connection_unref_locked((p), __FILE__, __LINE__, (r)) +#define SUBCHANNEL_REF_LOCKED(p, r) \ + subchannel_ref_locked((p), __FILE__, __LINE__, (r)) +#define SUBCHANNEL_UNREF_LOCKED(p, r) \ + subchannel_unref_locked((p), __FILE__, __LINE__, (r)) +#define CONNECTION_REF_LOCKED(p, r) \ + connection_ref_locked((p), __FILE__, __LINE__, (r)) +#define CONNECTION_UNREF_LOCKED(p, r) \ + connection_unref_locked((p), __FILE__, __LINE__, (r)) #define REF_PASS_ARGS , file, line, reason -#define REF_LOG(name, p) gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "%s: %p ref %d -> %d %s", (name), (p), (p)->refs, (p)->refs + 1, reason) -#define UNREF_LOG(name, p) gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "%s: %p unref %d -> %d %s", (name), (p), (p)->refs, (p)->refs - 1, reason) +#define REF_LOG(name, p) \ + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "%s: %p ref %d -> %d %s", \ + (name), (p), (p)->refs, (p)->refs + 1, reason) +#define UNREF_LOG(name, p) \ + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "%s: %p unref %d -> %d %s", \ + (name), (p), (p)->refs, (p)->refs - 1, reason) #else #define SUBCHANNEL_REF_LOCKED(p, r) subchannel_ref_locked((p)) #define SUBCHANNEL_UNREF_LOCKED(p, r) subchannel_unref_locked((p)) @@ -174,13 +184,15 @@ static void connection_destroy(connection *c) { gpr_free(c); } -static void connection_ref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { +static void connection_ref_locked( + connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { REF_LOG("CONNECTION", c); subchannel_ref_locked(c->subchannel REF_PASS_ARGS); ++c->refs; } -static grpc_subchannel *connection_unref_locked(connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { +static grpc_subchannel *connection_unref_locked( + connection *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { grpc_subchannel *destroy = NULL; UNREF_LOG("CONNECTION", c); if (subchannel_unref_locked(c->subchannel REF_PASS_ARGS)) { @@ -196,12 +208,14 @@ static grpc_subchannel *connection_unref_locked(connection *c GRPC_SUBCHANNEL_RE * grpc_subchannel implementation */ -static void subchannel_ref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { +static void subchannel_ref_locked( + grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { REF_LOG("SUBCHANNEL", c); - ++c->refs; + ++c->refs; } -static int subchannel_unref_locked(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { +static int subchannel_unref_locked( + grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { UNREF_LOG("SUBCHANNEL", c); return --c->refs == 0; } @@ -385,7 +399,8 @@ void grpc_subchannel_process_transport_op(grpc_subchannel *c, if (con != NULL) { grpc_channel_stack *channel_stack = CHANNEL_STACK_FROM_CONNECTION(con); - grpc_channel_element *top_elem = grpc_channel_stack_element(channel_stack, 0); + grpc_channel_element *top_elem = + grpc_channel_stack_element(channel_stack, 0); top_elem->filter->start_transport_op(top_elem, op); gpr_mu_lock(&c->mu); @@ -485,7 +500,8 @@ static void publish_transport(grpc_subchannel *c) { stk = (grpc_channel_stack *)(con + 1); con->refs = 0; con->subchannel = c; - grpc_channel_stack_init(filters, num_filters, c->master, c->args, c->mdctx, stk); + grpc_channel_stack_init(filters, num_filters, c->master, c->args, c->mdctx, + stk); grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); gpr_free(c->connecting_result.filters); memset(&c->connecting_result, 0, sizeof(c->connecting_result)); @@ -601,11 +617,13 @@ static void connectivity_state_changed_locked(grpc_subchannel *c) { * grpc_subchannel_call implementation */ -void grpc_subchannel_call_ref(grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { - gpr_ref(&c->refs); +void grpc_subchannel_call_ref( + grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { + gpr_ref(&c->refs); } -void grpc_subchannel_call_unref(grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { +void grpc_subchannel_call_unref( + grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { if (gpr_unref(&c->refs)) { gpr_mu *mu = &c->connection->subchannel->mu; grpc_subchannel *destroy; diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 5435ef703b3..a23a623277f 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -44,11 +44,16 @@ typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; #ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG -#define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p), __FILE__, __LINE__, (r)) -#define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p), __FILE__, __LINE__, (r)) -#define GRPC_SUBCHANNEL_CALL_REF(p, r) grpc_subchannel_call_ref((p), __FILE__, __LINE__, (r)) -#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) grpc_subchannel_call_unref((p), __FILE__, __LINE__, (r)) -#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS , const char *file, int line, const char *reason +#define GRPC_SUBCHANNEL_REF(p, r) \ + grpc_subchannel_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_UNREF(p, r) \ + grpc_subchannel_unref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_CALL_REF(p, r) \ + grpc_subchannel_call_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) \ + grpc_subchannel_call_unref((p), __FILE__, __LINE__, (r)) +#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS \ + , const char *file, int line, const char *reason #else #define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p)) #define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p)) @@ -57,10 +62,14 @@ typedef struct grpc_subchannel_args grpc_subchannel_args; #define GRPC_SUBCHANNEL_REF_EXTRA_ARGS #endif -void grpc_subchannel_ref(grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); -void grpc_subchannel_unref(grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); -void grpc_subchannel_call_ref(grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS); -void grpc_subchannel_call_unref(grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_subchannel_ref( + grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_subchannel_unref( + grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_subchannel_call_ref( + grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_subchannel_call_unref( + grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS); /** construct a call (possibly asynchronously) */ void grpc_subchannel_create_call(grpc_subchannel *subchannel, diff --git a/src/core/client_config/uri_parser.c b/src/core/client_config/uri_parser.c index c5faab5eba0..776a2559231 100644 --- a/src/core/client_config/uri_parser.c +++ b/src/core/client_config/uri_parser.c @@ -39,7 +39,8 @@ #include #include -static grpc_uri *bad_uri(const char *uri_text, int pos, const char *section, int suppress_errors) { +static grpc_uri *bad_uri(const char *uri_text, int pos, const char *section, + int suppress_errors) { char *line_prefix; int pfx_len; diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 446081954db..afecccae170 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -199,7 +199,8 @@ static void wake_all_watchers_locked(grpc_fd *fd) { } static int has_watchers(grpc_fd *fd) { - return fd->read_watcher != NULL || fd->write_watcher != NULL || fd->inactive_watcher_root.next != &fd->inactive_watcher_root; + return fd->read_watcher != NULL || fd->write_watcher != NULL || + fd->inactive_watcher_root.next != &fd->inactive_watcher_root; } void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_closure *on_done, diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index 93bf846978c..5d04ec49b24 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -280,7 +280,7 @@ static void destroy_call_elem(grpc_call_element *elem) { } /* Constructor for channel_data */ -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { @@ -326,6 +326,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_client_auth_filter = { - auth_start_transport_op, grpc_channel_next_op, sizeof(call_data), + auth_start_transport_op, grpc_channel_next_op, sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem, "client-auth"}; diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c index a92b46c85f7..a0dbeb58cd2 100644 --- a/src/core/security/server_auth_filter.c +++ b/src/core/security/server_auth_filter.c @@ -84,8 +84,7 @@ static void init_call_elem(grpc_call_element *elem, } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element *elem) { -} +static void destroy_call_elem(grpc_call_element *elem) {} /* Constructor for channel_data */ static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, @@ -115,6 +114,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_server_auth_filter = { - auth_start_transport_op, grpc_channel_next_op, sizeof(call_data), init_call_elem, - destroy_call_elem, sizeof(channel_data), init_channel_elem, - destroy_channel_elem, "server-auth"}; + auth_start_transport_op, grpc_channel_next_op, sizeof(call_data), + init_call_elem, destroy_call_elem, sizeof(channel_data), + init_channel_elem, destroy_channel_elem, "server-auth"}; diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c index 018ec3d1d7f..2e49e370f75 100644 --- a/src/core/security/server_secure_chttp2.c +++ b/src/core/security/server_secure_chttp2.c @@ -75,9 +75,8 @@ static void state_unref(grpc_server_secure_state *state) { } } -static void setup_transport(void *statep, - grpc_transport *transport, - grpc_mdctx *mdctx) { +static void setup_transport(void *statep, grpc_transport *transport, + grpc_mdctx *mdctx) { static grpc_channel_filter const *extra_filters[] = { &grpc_server_auth_filter, &grpc_http_server_filter}; grpc_server_secure_state *state = statep; @@ -85,8 +84,7 @@ static void setup_transport(void *statep, grpc_channel_args *args_copy = grpc_channel_args_copy_and_add( grpc_server_get_channel_args(state->server), &connector_arg, 1); grpc_server_setup_transport(state->server, transport, extra_filters, - GPR_ARRAY_SIZE(extra_filters), mdctx, - args_copy); + GPR_ARRAY_SIZE(extra_filters), mdctx, args_copy); grpc_channel_args_destroy(args_copy); } @@ -101,8 +99,8 @@ static void on_secure_transport_setup_done(void *statep, if (!state->is_shutdown) { mdctx = grpc_mdctx_create(); transport = grpc_create_chttp2_transport( - grpc_server_get_channel_args(state->server), - secure_endpoint, NULL, 0, mdctx, 0); + grpc_server_get_channel_args(state->server), secure_endpoint, NULL, 0, + mdctx, 0); setup_transport(state, transport, mdctx); } else { /* We need to consume this here, because the server may already have gone diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 84ae038e464..8550056bcbc 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -462,8 +462,7 @@ static int need_more_data(grpc_call *call) { (is_op_live(call, GRPC_IOREQ_RECV_CLOSE) && grpc_bbq_empty(&call->incoming_queue)) || (call->write_state == WRITE_STATE_INITIAL && !call->is_client) || - (call->cancel_with_status != GRPC_STATUS_OK) || - call->destroy_called; + (call->cancel_with_status != GRPC_STATUS_OK) || call->destroy_called; } static void unlock(grpc_call *call) { @@ -1151,7 +1150,8 @@ static void execute_op(grpc_call *call, grpc_transport_stream_op *op) { } else { finished_loose_op_allocated_args *args = gpr_malloc(sizeof(*args)); args->call = call; - grpc_iomgr_closure_init(&args->closure, finished_loose_op_allocated, args); + grpc_iomgr_closure_init(&args->closure, finished_loose_op_allocated, + args); op->on_consumed = &args->closure; } } @@ -1223,13 +1223,13 @@ static gpr_uint32 decode_compression(grpc_mdelem *md) { } else { gpr_uint32 parsed_clevel_bytes; if (gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), - GPR_SLICE_LENGTH(md->value->slice), - &parsed_clevel_bytes)) { + GPR_SLICE_LENGTH(md->value->slice), + &parsed_clevel_bytes)) { /* the following cast is safe, as a gpr_uint32 should be able to hold all * possible values of the grpc_compression_level enum */ - clevel = (grpc_compression_level) parsed_clevel_bytes; + clevel = (grpc_compression_level)parsed_clevel_bytes; } else { - clevel = GRPC_COMPRESS_LEVEL_NONE; /* could not parse, no compression */ + clevel = GRPC_COMPRESS_LEVEL_NONE; /* could not parse, no compression */ } grpc_mdelem_set_user_data(md, destroy_compression, (void *)(gpr_intptr)(clevel + COMPRESS_OFFSET)); @@ -1252,7 +1252,8 @@ static void recv_metadata(grpc_call *call, grpc_metadata_batch *md) { set_status_code(call, STATUS_FROM_WIRE, decode_status(md)); } else if (key == grpc_channel_get_message_string(call->channel)) { set_status_details(call, STATUS_FROM_WIRE, grpc_mdstr_ref(md->value)); - } else if (key == grpc_channel_get_compresssion_level_string(call->channel)) { + } else if (key == + grpc_channel_get_compresssion_level_string(call->channel)) { set_decode_compression_level(call, decode_compression(md)); } else { dest = &call->buffered_metadata[is_trailing]; diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index e85eaf2c056..f8151c121c3 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -129,7 +129,8 @@ grpc_channel *grpc_channel_create_from_filters( } } - grpc_channel_stack_init(filters, num_filters, channel, args, channel->metadata_context, + grpc_channel_stack_init(filters, num_filters, channel, args, + channel->metadata_context, CHANNEL_STACK_FROM_CHANNEL(channel)); return channel; @@ -264,7 +265,6 @@ grpc_mdstr *grpc_channel_get_compresssion_level_string(grpc_channel *channel) { return channel->grpc_compression_level_string; } - grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_channel *channel, int i) { if (i >= 0 && i < NUM_CACHED_STATUS_ELEMS) { return grpc_mdelem_ref(channel->grpc_status_elem[i]); diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 20da8303881..280927834b9 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -71,10 +71,10 @@ static void connected(void *arg, grpc_endpoint *tcp) { connector *c = arg; grpc_iomgr_closure *notify; if (tcp != NULL) { - c->result->transport = - grpc_create_chttp2_transport(c->args.channel_args, tcp, NULL, 0, c->args.metadata_context, 1); + c->result->transport = grpc_create_chttp2_transport( + c->args.channel_args, tcp, NULL, 0, c->args.metadata_context, 1); GPR_ASSERT(c->result->transport); - c->result->filters = gpr_malloc(sizeof(grpc_channel_filter*)); + c->result->filters = gpr_malloc(sizeof(grpc_channel_filter *)); c->result->filters[0] = &grpc_http_client_filter; c->result->num_filters = 1; } else { @@ -85,19 +85,22 @@ static void connected(void *arg, grpc_endpoint *tcp) { grpc_iomgr_add_callback(notify); } -static void connector_connect( - grpc_connector *con, const grpc_connect_in_args *args, - grpc_connect_out_args *result, grpc_iomgr_closure *notify) { +static void connector_connect(grpc_connector *con, + const grpc_connect_in_args *args, + grpc_connect_out_args *result, + grpc_iomgr_closure *notify) { connector *c = (connector *)con; GPR_ASSERT(c->notify == NULL); GPR_ASSERT(notify->cb); c->notify = notify; c->args = *args; c->result = result; - grpc_tcp_client_connect(connected, c, args->interested_parties, args->addr, args->addr_len, args->deadline); + grpc_tcp_client_connect(connected, c, args->interested_parties, args->addr, + args->addr_len, args->deadline); } -static const grpc_connector_vtable connector_vtable = {connector_ref, connector_unref, connector_connect}; +static const grpc_connector_vtable connector_vtable = { + connector_ref, connector_unref, connector_connect}; typedef struct { grpc_subchannel_factory base; @@ -119,7 +122,8 @@ static void subchannel_factory_unref(grpc_subchannel_factory *scf) { } } -static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { +static grpc_subchannel *subchannel_factory_create_subchannel( + grpc_subchannel_factory *scf, grpc_subchannel_args *args) { subchannel_factory *f = (subchannel_factory *)scf; connector *c = gpr_malloc(sizeof(*c)); grpc_channel_args *final_args = @@ -136,7 +140,9 @@ static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_fac return s; } -static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchannel_factory_ref, subchannel_factory_unref, subchannel_factory_create_subchannel}; +static const grpc_subchannel_factory_vtable subchannel_factory_vtable = { + subchannel_factory_ref, subchannel_factory_unref, + subchannel_factory_create_subchannel}; /* Create a client channel: Asynchronously: - resolve target @@ -170,7 +176,8 @@ grpc_channel *grpc_channel_create(const char *target, } channel = grpc_channel_create_from_filters(filters, n, args, mdctx, 1); - grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); + grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), + resolver); GRPC_RESOLVER_UNREF(resolver, "create"); grpc_subchannel_factory_unref(&f->base); diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index c6ac6798716..3dd56fe5a96 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -105,7 +105,7 @@ static void init_call_elem(grpc_call_element *elem, static void destroy_call_elem(grpc_call_element *elem) {} -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { channel_data *chand = elem->channel_data; diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index d3550792609..998acfc8cf6 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -82,9 +82,9 @@ static void on_secure_transport_setup_done(void *arg, gpr_log(GPR_ERROR, "Secure transport setup failed with error %d.", status); memset(c->result, 0, sizeof(*c->result)); } else { - c->result->transport = grpc_create_chttp2_transport( - c->args.channel_args, secure_endpoint, - NULL, 0, c->args.metadata_context, 1); + c->result->transport = + grpc_create_chttp2_transport(c->args.channel_args, secure_endpoint, + NULL, 0, c->args.metadata_context, 1); c->result->filters = gpr_malloc(sizeof(grpc_channel_filter *) * 2); c->result->filters[0] = &grpc_client_auth_filter; c->result->filters[1] = &grpc_http_client_filter; @@ -109,19 +109,22 @@ static void connected(void *arg, grpc_endpoint *tcp) { } } -static void connector_connect( - grpc_connector *con, const grpc_connect_in_args *args, - grpc_connect_out_args *result, grpc_iomgr_closure *notify) { +static void connector_connect(grpc_connector *con, + const grpc_connect_in_args *args, + grpc_connect_out_args *result, + grpc_iomgr_closure *notify) { connector *c = (connector *)con; GPR_ASSERT(c->notify == NULL); GPR_ASSERT(notify->cb); c->notify = notify; c->args = *args; c->result = result; - grpc_tcp_client_connect(connected, c, args->interested_parties, args->addr, args->addr_len, args->deadline); + grpc_tcp_client_connect(connected, c, args->interested_parties, args->addr, + args->addr_len, args->deadline); } -static const grpc_connector_vtable connector_vtable = {connector_ref, connector_unref, connector_connect}; +static const grpc_connector_vtable connector_vtable = { + connector_ref, connector_unref, connector_connect}; typedef struct { grpc_subchannel_factory base; @@ -144,7 +147,8 @@ static void subchannel_factory_unref(grpc_subchannel_factory *scf) { } } -static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_factory *scf, grpc_subchannel_args *args) { +static grpc_subchannel *subchannel_factory_create_subchannel( + grpc_subchannel_factory *scf, grpc_subchannel_args *args) { subchannel_factory *f = (subchannel_factory *)scf; connector *c = gpr_malloc(sizeof(*c)); grpc_channel_args *final_args = @@ -162,7 +166,9 @@ static grpc_subchannel *subchannel_factory_create_subchannel(grpc_subchannel_fac return s; } -static const grpc_subchannel_factory_vtable subchannel_factory_vtable = {subchannel_factory_ref, subchannel_factory_unref, subchannel_factory_create_subchannel}; +static const grpc_subchannel_factory_vtable subchannel_factory_vtable = { + subchannel_factory_ref, subchannel_factory_unref, + subchannel_factory_create_subchannel}; /* Create a secure client channel: Asynchronously: - resolve target @@ -219,7 +225,8 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, } channel = grpc_channel_create_from_filters(filters, n, args_copy, mdctx, 1); - grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); + grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), + resolver); GRPC_RESOLVER_UNREF(resolver, "create"); grpc_channel_args_destroy(args_copy); diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 703eeaf2bd5..c883d08a02e 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -151,7 +151,7 @@ struct grpc_server { before mu_call. This is currently used in shutdown processing (grpc_server_shutdown_and_notify and maybe_finish_shutdown) */ gpr_mu mu_global; /* mutex for server and channel state */ - gpr_mu mu_call; /* mutex for call-specific state */ + gpr_mu mu_call; /* mutex for call-specific state */ registered_method *registered_methods; requested_call_array requested_calls; @@ -226,11 +226,10 @@ static void channel_broadcaster_init(grpc_server *s, channel_broadcaster *cb) { channel_data *c; size_t count = 0; size_t dc_count = 0; - for (c = s->root_channel_data.next; c != &s->root_channel_data; - c = c->next) { - count ++; + for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) { + count++; if (c->num_calls == 0) { - dc_count ++; + dc_count++; } } cb->num_channels = count; @@ -239,8 +238,7 @@ static void channel_broadcaster_init(grpc_server *s, channel_broadcaster *cb) { cb->disconnects = gpr_malloc(sizeof(*cb->channels) * cb->num_disconnects); count = 0; dc_count = 0; - for (c = s->root_channel_data.next; c != &s->root_channel_data; - c = c->next) { + for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) { cb->channels[count++] = c->channel; GRPC_CHANNEL_INTERNAL_REF(c->channel, "broadcast"); if (c->num_calls == 0) { @@ -261,7 +259,8 @@ static void shutdown_cleanup(void *arg, int iomgr_status_ignored) { gpr_free(a); } -static void send_shutdown(grpc_channel *channel, int send_goaway, int send_disconnect) { +static void send_shutdown(grpc_channel *channel, int send_goaway, + int send_disconnect) { grpc_transport_op op; struct shutdown_cleanup_args *sc; grpc_channel_element *elem; @@ -277,12 +276,12 @@ static void send_shutdown(grpc_channel *channel, int send_goaway, int send_disco grpc_iomgr_closure_init(&sc->closure, shutdown_cleanup, sc); op.on_consumed = &sc->closure; - elem = grpc_channel_stack_element( - grpc_channel_get_channel_stack(channel), 0); + elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0); elem->filter->start_transport_op(elem, &op); } -static void channel_broadcaster_shutdown(channel_broadcaster *cb, int send_goaway, int send_disconnect) { +static void channel_broadcaster_shutdown(channel_broadcaster *cb, + int send_goaway, int send_disconnect) { size_t i; for (i = 0; i < cb->num_channels; i++) { @@ -721,7 +720,7 @@ static void destroy_call_elem(grpc_call_element *elem) { server_unref(chand->server); } -static void init_channel_elem(grpc_channel_element *elem,grpc_channel *master, +static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index e32071e6927..d8001d6c324 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -117,7 +117,9 @@ static void add_to_pollset_locked(grpc_chttp2_transport *t, static void maybe_start_some_streams( grpc_chttp2_transport_global *transport_global); -static void connectivity_state_set(grpc_chttp2_transport_global *transport_global, grpc_connectivity_state state); +static void connectivity_state_set( + grpc_chttp2_transport_global *transport_global, + grpc_connectivity_state state); /* * CONSTRUCTION/DESTRUCTION/REFCOUNTING @@ -330,8 +332,7 @@ static void destroy_transport(grpc_transport *gt) { static void close_transport_locked(grpc_chttp2_transport *t) { if (!t->closed) { t->closed = 1; - connectivity_state_set(&t->global, - GRPC_CHANNEL_FATAL_FAILURE); + connectivity_state_set(&t->global, GRPC_CHANNEL_FATAL_FAILURE); if (t->ep) { grpc_endpoint_shutdown(t->ep); } @@ -339,7 +340,8 @@ static void close_transport_locked(grpc_chttp2_transport *t) { } static int init_stream(grpc_transport *gt, grpc_stream *gs, - const void *server_data, grpc_transport_stream_op *initial_op) { + const void *server_data, + grpc_transport_stream_op *initial_op) { grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt; grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs; @@ -521,14 +523,13 @@ static void writing_action(void *gt, int iomgr_success_ignored) { void grpc_chttp2_add_incoming_goaway( grpc_chttp2_transport_global *transport_global, gpr_uint32 goaway_error, gpr_slice goaway_text) { - char *msg = gpr_hexdump((char*)GPR_SLICE_START_PTR(goaway_text), GPR_SLICE_LENGTH(goaway_text), GPR_HEXDUMP_PLAINTEXT); + char *msg = gpr_hexdump((char *)GPR_SLICE_START_PTR(goaway_text), + GPR_SLICE_LENGTH(goaway_text), GPR_HEXDUMP_PLAINTEXT); gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg); gpr_free(msg); gpr_slice_unref(goaway_text); transport_global->seen_goaway = 1; - connectivity_state_set( - transport_global, - GRPC_CHANNEL_FATAL_FAILURE); + connectivity_state_set(transport_global, GRPC_CHANNEL_FATAL_FAILURE); } static void maybe_start_some_streams( @@ -735,9 +736,8 @@ static void remove_stream(grpc_chttp2_transport *t, gpr_uint32 id) { grpc_chttp2_parsing_become_skip_parser(&t->parsing); } - new_stream_count = - grpc_chttp2_stream_map_size(&t->parsing_stream_map) + - grpc_chttp2_stream_map_size(&t->new_stream_map); + new_stream_count = grpc_chttp2_stream_map_size(&t->parsing_stream_map) + + grpc_chttp2_stream_map_size(&t->new_stream_map); if (new_stream_count != t->global.concurrent_stream_count) { t->global.concurrent_stream_count = new_stream_count; maybe_start_some_streams(&t->global); @@ -772,11 +772,12 @@ static void unlock_check_read_write_state(grpc_chttp2_transport *t) { if (!stream_global->published_cancelled) { char buffer[GPR_LTOA_MIN_BUFSIZE]; gpr_ltoa(stream_global->cancelled_status, buffer); - grpc_chttp2_incoming_metadata_buffer_add(&stream_global->incoming_metadata, - grpc_mdelem_from_strings(t->metadata_context, "grpc-status", buffer)); + grpc_chttp2_incoming_metadata_buffer_add( + &stream_global->incoming_metadata, + grpc_mdelem_from_strings(t->metadata_context, "grpc-status", + buffer)); grpc_chttp2_incoming_metadata_buffer_place_metadata_batch_into( - &stream_global->incoming_metadata, - &stream_global->incoming_sopb); + &stream_global->incoming_metadata, &stream_global->incoming_sopb); stream_global->published_cancelled = 1; } } @@ -825,10 +826,10 @@ static void cancel_from_api(grpc_chttp2_transport_global *transport_global, stream_global->cancelled = 1; stream_global->cancelled_status = status; if (stream_global->id != 0) { - gpr_slice_buffer_add(&transport_global->qbuf, - grpc_chttp2_rst_stream_create( - stream_global->id, - grpc_chttp2_grpc_status_to_http2_error(status))); + gpr_slice_buffer_add( + &transport_global->qbuf, + grpc_chttp2_rst_stream_create( + stream_global->id, grpc_chttp2_grpc_status_to_http2_error(status))); } grpc_chttp2_list_add_read_write_state_changed(transport_global, stream_global); @@ -907,7 +908,8 @@ static void recv_data(void *tp, gpr_slice *slices, size_t nslices, /* merge stream lists */ grpc_chttp2_stream_map_move_into(&t->new_stream_map, &t->parsing_stream_map); - t->global.concurrent_stream_count = grpc_chttp2_stream_map_size(&t->parsing_stream_map); + t->global.concurrent_stream_count = + grpc_chttp2_stream_map_size(&t->parsing_stream_map); if (t->parsing.initial_window_update != 0) { grpc_chttp2_stream_map_for_each(&t->parsing_stream_map, update_global_window, t); @@ -934,17 +936,19 @@ static void reading_action(void *pt, int iomgr_success_ignored) { * CALLBACK LOOP */ -static void schedule_closure_for_connectivity(void *a, grpc_iomgr_closure *closure) { +static void schedule_closure_for_connectivity(void *a, + grpc_iomgr_closure *closure) { grpc_chttp2_schedule_closure(a, closure, 1); } -static void connectivity_state_set(grpc_chttp2_transport_global *transport_global, grpc_connectivity_state state) { - GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_DEBUG, "set connectivity_state=%d", state)); +static void connectivity_state_set( + grpc_chttp2_transport_global *transport_global, + grpc_connectivity_state state) { + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_DEBUG, "set connectivity_state=%d", state)); grpc_connectivity_state_set_with_scheduler( - &TRANSPORT_FROM_GLOBAL(transport_global)->channel_callback.state_tracker, - state, - schedule_closure_for_connectivity, - transport_global); + &TRANSPORT_FROM_GLOBAL(transport_global)->channel_callback.state_tracker, + state, schedule_closure_for_connectivity, transport_global); } void grpc_chttp2_schedule_closure( diff --git a/src/core/transport/connectivity_state.c b/src/core/transport/connectivity_state.c index 9a956a5a588..dabe46badd7 100644 --- a/src/core/transport/connectivity_state.c +++ b/src/core/transport/connectivity_state.c @@ -81,8 +81,7 @@ int grpc_connectivity_state_notify_on_state_change( void grpc_connectivity_state_set_with_scheduler( grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state, - void (*scheduler)(void *arg, grpc_iomgr_closure *closure), - void *arg) { + void (*scheduler)(void *arg, grpc_iomgr_closure *closure), void *arg) { grpc_connectivity_state_watcher *new = NULL; grpc_connectivity_state_watcher *w; /*gpr_log(GPR_DEBUG, "CS:%p:set:%d", tracker, state);*/ @@ -111,5 +110,6 @@ static void default_scheduler(void *ignored, grpc_iomgr_closure *closure) { void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state) { - grpc_connectivity_state_set_with_scheduler(tracker, state, default_scheduler, NULL); + grpc_connectivity_state_set_with_scheduler(tracker, state, default_scheduler, + NULL); } diff --git a/src/core/transport/connectivity_state.h b/src/core/transport/connectivity_state.h index c6f903a1ea6..bbdcbcb0691 100644 --- a/src/core/transport/connectivity_state.h +++ b/src/core/transport/connectivity_state.h @@ -61,8 +61,7 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state); void grpc_connectivity_state_set_with_scheduler( grpc_connectivity_state_tracker *tracker, grpc_connectivity_state state, - void (*scheduler)(void *arg, grpc_iomgr_closure *closure), - void *arg); + void (*scheduler)(void *arg, grpc_iomgr_closure *closure), void *arg); grpc_connectivity_state grpc_connectivity_state_check( grpc_connectivity_state_tracker *tracker); diff --git a/src/core/transport/transport.c b/src/core/transport/transport.c index c29217599e0..1397e21933c 100644 --- a/src/core/transport/transport.c +++ b/src/core/transport/transport.c @@ -49,8 +49,9 @@ int grpc_transport_init_stream(grpc_transport *transport, grpc_stream *stream, initial_op); } -void grpc_transport_perform_stream_op(grpc_transport *transport, grpc_stream *stream, - grpc_transport_stream_op *op) { +void grpc_transport_perform_stream_op(grpc_transport *transport, + grpc_stream *stream, + grpc_transport_stream_op *op) { transport->vtable->perform_stream_op(transport, stream, op); } diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h index 24a02132e95..599edc871fb 100644 --- a/src/core/transport/transport.h +++ b/src/core/transport/transport.h @@ -99,7 +99,8 @@ typedef struct grpc_transport_op { gpr_slice *goaway_message; /** set the callback for accepting new streams; this is a permanent callback, unlike the other one-shot closures */ - void (*set_accept_stream)(void *user_data, grpc_transport *transport, const void *server_data); + void (*set_accept_stream)(void *user_data, grpc_transport *transport, + const void *server_data); void *set_accept_stream_user_data; /** add this transport to a pollset */ grpc_pollset *bind_pollset; @@ -154,10 +155,12 @@ char *grpc_transport_stream_op_string(grpc_transport_stream_op *op); stream - the stream on which to send the operations. This must be non-NULL and previously initialized by the same transport. op - a grpc_transport_stream_op specifying the op to perform */ -void grpc_transport_perform_stream_op(grpc_transport *transport, grpc_stream *stream, - grpc_transport_stream_op *op); +void grpc_transport_perform_stream_op(grpc_transport *transport, + grpc_stream *stream, + grpc_transport_stream_op *op); -void grpc_transport_perform_op(grpc_transport *transport, grpc_transport_op *op); +void grpc_transport_perform_op(grpc_transport *transport, + grpc_transport_op *op); /* Send a ping on a transport diff --git a/src/core/transport/transport_impl.h b/src/core/transport/transport_impl.h index b18f9570095..515721dfb68 100644 --- a/src/core/transport/transport_impl.h +++ b/src/core/transport/transport_impl.h @@ -48,7 +48,7 @@ typedef struct grpc_transport_vtable { /* implementation of grpc_transport_perform_stream_op */ void (*perform_stream_op)(grpc_transport *self, grpc_stream *stream, - grpc_transport_stream_op *op); + grpc_transport_stream_op *op); /* implementation of grpc_transport_perform_op */ void (*perform_op)(grpc_transport *self, grpc_transport_op *op); diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 4b889995a18..0b0a682607c 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -63,14 +63,14 @@ static void done_write(void *arg, grpc_endpoint_cb_status status) { gpr_event_set(&a->done_write, (void *)1); } -static void server_setup_transport( - void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { +static void server_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { thd_args *a = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; grpc_server_setup_transport(a->server, transport, extra_filters, - GPR_ARRAY_SIZE(extra_filters), mdctx, - grpc_server_get_channel_args(a->server)); + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(a->server)); } void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, @@ -105,8 +105,7 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, a.validator = validator; grpc_server_register_completion_queue(a.server, a.cq); grpc_server_start(a.server); - transport = grpc_create_chttp2_transport(NULL, sfd.server, - NULL, 0, mdctx, 0); + transport = grpc_create_chttp2_transport(NULL, sfd.server, NULL, 0, mdctx, 0); server_setup_transport(&a, transport, mdctx); /* Bind everything into the same pollset */ diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index 55a15a1a549..eca2a40c979 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -39,7 +39,7 @@ #include #include "test/core/util/test_config.h" -static void channel_init_func(grpc_channel_element *elem,grpc_channel *master, +static void channel_init_func(grpc_channel_element *elem, grpc_channel *master, const grpc_channel_args *args, grpc_mdctx *metadata_context, int is_first, int is_last) { @@ -75,8 +75,9 @@ static void channel_func(grpc_channel_element *elem, grpc_transport_op *op) { static void test_create_channel_stack(void) { const grpc_channel_filter filter = { - call_func, channel_func, sizeof(int), call_init_func, call_destroy_func, - sizeof(int), channel_init_func, channel_destroy_func, "some_test_filter"}; + call_func, channel_func, sizeof(int), + call_init_func, call_destroy_func, sizeof(int), + channel_init_func, channel_destroy_func, "some_test_filter"}; const grpc_channel_filter *filters = &filter; grpc_channel_stack *channel_stack; grpc_call_stack *call_stack; diff --git a/test/core/end2end/fixtures/chttp2_socket_pair.c b/test/core/end2end/fixtures/chttp2_socket_pair.c index 9f3b36d5e9e..f42b9831c8d 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair.c @@ -55,14 +55,14 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void server_setup_transport( - void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { +static void server_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; grpc_server_setup_transport(f->server, transport, extra_filters, - GPR_ARRAY_SIZE(extra_filters), mdctx, - grpc_server_get_channel_args(f->server)); + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(f->server)); } typedef struct { @@ -70,8 +70,8 @@ typedef struct { grpc_channel_args *client_args; } sp_client_setup; -static void client_setup_transport( - void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { +static void client_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { sp_client_setup *cs = ts; const grpc_channel_filter *filters[] = {&grpc_http_client_filter, @@ -82,8 +82,8 @@ static void client_setup_transport( cs->f->client = channel; - grpc_connected_channel_bind_transport( - grpc_channel_get_channel_stack(channel), transport); + grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel), + transport); } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( @@ -108,8 +108,8 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = grpc_create_chttp2_transport(client_args, - sfd->client, NULL, 0, mdctx, 1); + transport = + grpc_create_chttp2_transport(client_args, sfd->client, NULL, 0, mdctx, 1); client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); } @@ -123,8 +123,8 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - transport = grpc_create_chttp2_transport(server_args, - sfd->server, NULL, 0, mdctx, 0); + transport = + grpc_create_chttp2_transport(server_args, sfd->server, NULL, 0, mdctx, 0); server_setup_transport(f, transport, mdctx); } diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c index d53a49edbfe..be520380a70 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c @@ -55,14 +55,14 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void server_setup_transport( - void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { +static void server_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; grpc_server_setup_transport(f->server, transport, extra_filters, - GPR_ARRAY_SIZE(extra_filters), mdctx, - grpc_server_get_channel_args(f->server)); + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(f->server)); } typedef struct { @@ -70,8 +70,8 @@ typedef struct { grpc_channel_args *client_args; } sp_client_setup; -static void client_setup_transport( - void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { +static void client_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { sp_client_setup *cs = ts; const grpc_channel_filter *filters[] = {&grpc_http_client_filter, @@ -82,8 +82,8 @@ static void client_setup_transport( cs->f->client = channel; - grpc_connected_channel_bind_transport( - grpc_channel_get_channel_stack(channel), transport); + grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel), + transport); } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( @@ -108,8 +108,8 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = grpc_create_chttp2_transport(client_args, - sfd->client, NULL, 0, mdctx, 1); + transport = + grpc_create_chttp2_transport(client_args, sfd->client, NULL, 0, mdctx, 1); client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); } @@ -123,8 +123,8 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - transport = grpc_create_chttp2_transport(server_args, - sfd->server, NULL, 0, mdctx, 0); + transport = + grpc_create_chttp2_transport(server_args, sfd->server, NULL, 0, mdctx, 0); server_setup_transport(f, transport, mdctx); } diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c index c63d8f3fe98..037281c5ade 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c @@ -56,14 +56,14 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void server_setup_transport( - void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { +static void server_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { &grpc_http_server_filter}; grpc_server_setup_transport(f->server, transport, extra_filters, - GPR_ARRAY_SIZE(extra_filters), mdctx, - grpc_server_get_channel_args(f->server)); + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(f->server)); } typedef struct { @@ -71,8 +71,8 @@ typedef struct { grpc_channel_args *client_args; } sp_client_setup; -static void client_setup_transport( - void *ts, grpc_transport *transport, grpc_mdctx *mdctx) { +static void client_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { sp_client_setup *cs = ts; const grpc_channel_filter *filters[] = {&grpc_http_client_filter, @@ -83,8 +83,8 @@ static void client_setup_transport( cs->f->client = channel; - grpc_connected_channel_bind_transport( - grpc_channel_get_channel_stack(channel), transport); + grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel), + transport); } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( @@ -109,8 +109,8 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = grpc_create_chttp2_transport(client_args, - sfd->client, NULL, 0, mdctx, 1); + transport = + grpc_create_chttp2_transport(client_args, sfd->client, NULL, 0, mdctx, 1); client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); } @@ -124,8 +124,8 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - transport = grpc_create_chttp2_transport(server_args, - sfd->server, NULL, 0, mdctx, 0); + transport = + grpc_create_chttp2_transport(server_args, sfd->server, NULL, 0, mdctx, 0); server_setup_transport(f, transport, mdctx); } diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c index 2d79f5adbdb..32f37b0973c 100644 --- a/test/core/end2end/multiple_server_queues_test.c +++ b/test/core/end2end/multiple_server_queues_test.c @@ -49,7 +49,7 @@ int main(int argc, char **argv) { grpc_server_register_completion_queue(server, cq2); grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq2, NULL); - grpc_completion_queue_next(cq2, gpr_inf_future); /* cue queue hang */ + grpc_completion_queue_next(cq2, gpr_inf_future); /* cue queue hang */ grpc_completion_queue_shutdown(cq1); grpc_completion_queue_shutdown(cq2); grpc_completion_queue_next(cq1, gpr_inf_future); diff --git a/test/core/iomgr/fd_conservation_posix_test.c b/test/core/iomgr/fd_conservation_posix_test.c index aa4551f2f1a..8327c681b81 100644 --- a/test/core/iomgr/fd_conservation_posix_test.c +++ b/test/core/iomgr/fd_conservation_posix_test.c @@ -40,9 +40,9 @@ #include "src/core/iomgr/iomgr.h" int main(int argc, char **argv) { - int i; - struct rlimit rlim; - grpc_endpoint_pair p; + int i; + struct rlimit rlim; + grpc_endpoint_pair p; grpc_test_init(argc, argv); grpc_iomgr_init(); @@ -53,9 +53,9 @@ int main(int argc, char **argv) { GPR_ASSERT(0 == setrlimit(RLIMIT_NOFILE, &rlim)); for (i = 0; i < 100; i++) { - p = grpc_iomgr_create_endpoint_pair("test", 1); - grpc_endpoint_destroy(p.client); - grpc_endpoint_destroy(p.server); + p = grpc_iomgr_create_endpoint_pair("test", 1); + grpc_endpoint_destroy(p.client); + grpc_endpoint_destroy(p.server); } grpc_iomgr_shutdown(); From 6806e1e526b4b71561d0a2613aed8d180c269940 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 10:28:29 -0700 Subject: [PATCH 077/124] Fix leaking channel args --- src/core/surface/channel_create.c | 1 + src/core/surface/secure_channel_create.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 280927834b9..09b4fb782b9 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -117,6 +117,7 @@ static void subchannel_factory_ref(grpc_subchannel_factory *scf) { static void subchannel_factory_unref(grpc_subchannel_factory *scf) { subchannel_factory *f = (subchannel_factory *)scf; if (gpr_unref(&f->refs)) { + grpc_channel_args_destroy(f->merge_args); grpc_mdctx_unref(f->mdctx); gpr_free(f); } diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index 998acfc8cf6..1dd9e61d0fc 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -142,6 +142,7 @@ static void subchannel_factory_ref(grpc_subchannel_factory *scf) { static void subchannel_factory_unref(grpc_subchannel_factory *scf) { subchannel_factory *f = (subchannel_factory *)scf; if (gpr_unref(&f->refs)) { + grpc_channel_args_destroy(f->merge_args); grpc_mdctx_unref(f->mdctx); gpr_free(f); } From fd1a20a667fc2cfdfe2afd8a8d54cb3f5438b5df Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Tue, 30 Jun 2015 16:38:32 -0700 Subject: [PATCH 078/124] Changes introduced for passing hashed user id instead of access token --- test/cpp/qps/perf_db.proto | 2 +- test/cpp/qps/perf_db_client.cc | 6 +++--- test/cpp/qps/perf_db_client.h | 2 +- test/cpp/qps/report.cc | 2 +- test/cpp/qps/report.h | 6 +++--- test/cpp/util/benchmark_config.cc | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/cpp/qps/perf_db.proto b/test/cpp/qps/perf_db.proto index 7a550f83c65..60e038406a8 100644 --- a/test/cpp/qps/perf_db.proto +++ b/test/cpp/qps/perf_db.proto @@ -57,7 +57,7 @@ message Metrics { // Request for storing a single user's data message SingleUserRecordRequest { - string access_token = 1; + string hashed_id = 1; string test_name = 2; string sys_info = 3; string tag = 4; diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 5ec87e150c6..0996ea2b27c 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -39,7 +39,7 @@ namespace testing { // sets the client and server config information void PerfDbClient::setConfigs(const ClientConfig& client_config, const ServerConfig& server_config) { - this->client_config_ = client_config; + client_config_ = client_config; this->server_config_ = server_config; } @@ -76,13 +76,13 @@ void PerfDbClient::setTimes(double server_system_time, double server_user_time, } // sends the data to the performance database server -bool PerfDbClient::sendData(std::string access_token, std::string test_name, +bool PerfDbClient::sendData(std::string hashed_id, std::string test_name, std::string sys_info, std::string tag) { // Data record request object SingleUserRecordRequest single_user_record_request; // setting access token, name of the test and the system information - single_user_record_request.set_access_token(access_token); + single_user_record_request.set_hashed_id(hashed_id); single_user_record_request.set_test_name(test_name); single_user_record_request.set_sys_info(sys_info); single_user_record_request.set_tag(tag); diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index a22426bced4..ce7a88bbff0 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -91,7 +91,7 @@ class PerfDbClient { double client_system_time, double client_user_time); // sends the data to the performance database server - bool sendData(std::string access_token, std::string test_name, + bool sendData(std::string hashed_id, std::string test_name, std::string sys_info, std::string tag); private: diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index da1dea62aec..ff01ec15014 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -172,7 +172,7 @@ void PerfDbReporter::ReportTimes(const ScenarioResult& result) { void PerfDbReporter::SendData() { // send data to performance database bool data_state = - perf_db_client_.sendData(access_token_, test_name_, sys_info_, tag_); + perf_db_client_.sendData(hashed_id_, test_name_, sys_info_, tag_); // check state of data sending if (data_state) { diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 88707bea387..aec3cbe80a3 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -107,11 +107,11 @@ class GprLogReporter : public Reporter { /** Reporter for performance database tool */ class PerfDbReporter : public Reporter { public: - PerfDbReporter(const string& name, const string& access_token, + PerfDbReporter(const string& name, const string& hashed_id, const string& test_name, const string& sys_info, const string& server_address, const string& tag) : Reporter(name), - access_token_(access_token), + hashed_id_(hashed_id), test_name_(test_name), sys_info_(sys_info), tag_(tag) { @@ -122,7 +122,7 @@ class PerfDbReporter : public Reporter { private: PerfDbClient perf_db_client_; - std::string access_token_; + std::string hashed_id_; std::string test_name_; std::string sys_info_; std::string tag_; diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 030cb28c32f..91fbbf96771 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -39,7 +39,7 @@ DEFINE_bool(enable_log_reporter, true, DEFINE_bool(report_metrics_db, false, "True if metrics to be reported to performance database"); -DEFINE_string(access_token, "", "Authorizing JSON string for leaderboard"); +DEFINE_string(hashed_id, "", "Hash of the user id"); DEFINE_string(test_name, "", "Name of the test being executed"); @@ -71,7 +71,7 @@ static std::shared_ptr InitBenchmarkReporters() { } if(FLAGS_report_metrics_db) { composite_reporter->add( - std::unique_ptr(new PerfDbReporter("PerfDbReporter", FLAGS_access_token, FLAGS_test_name, + std::unique_ptr(new PerfDbReporter("PerfDbReporter", FLAGS_hashed_id, FLAGS_test_name, FLAGS_sys_info, FLAGS_server_address, FLAGS_tag))); } From a90c81ea61a736729598ae64c7c4a6ba2e2267ff Mon Sep 17 00:00:00 2001 From: Siddharth Rakesh Date: Tue, 30 Jun 2015 20:29:35 -0700 Subject: [PATCH 079/124] Removing this pointers --- test/cpp/qps/perf_db_client.cc | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 0996ea2b27c..08d20f0b8d8 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -40,17 +40,17 @@ namespace testing { void PerfDbClient::setConfigs(const ClientConfig& client_config, const ServerConfig& server_config) { client_config_ = client_config; - this->server_config_ = server_config; + server_config_ = server_config; } // sets the QPS void PerfDbClient::setQps(double qps) { - this->qps_ = qps; + qps_ = qps; } // sets the QPS per core void PerfDbClient::setQpsPerCore(double qps_per_core) { - this->qps_per_core_ = qps_per_core; + qps_per_core_ = qps_per_core; } // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency @@ -59,20 +59,20 @@ void PerfDbClient::setLatencies(double perc_lat_50, double perc_lat_95, double perc_lat_99, double perc_lat_99_point_9) { - this->perc_lat_50_ = perc_lat_50; - this->perc_lat_90_ = perc_lat_90; - this->perc_lat_95_ = perc_lat_95; - this->perc_lat_99_ = perc_lat_99; - this->perc_lat_99_point_9_ = perc_lat_99_point_9; + perc_lat_50_ = perc_lat_50; + perc_lat_90_ = perc_lat_90; + perc_lat_95_ = perc_lat_95; + perc_lat_99_ = perc_lat_99; + perc_lat_99_point_9_ = perc_lat_99_point_9; } // sets the server and client, user and system times void PerfDbClient::setTimes(double server_system_time, double server_user_time, double client_system_time, double client_user_time) { - this->server_system_time_ = server_system_time; - this->server_user_time_ = server_user_time; - this->client_system_time_ = client_system_time; - this->client_user_time_ = client_user_time; + server_system_time_ = server_system_time; + server_user_time_ = server_user_time; + client_system_time_ = client_system_time; + client_user_time_ = client_user_time; } // sends the data to the performance database server @@ -88,44 +88,44 @@ bool PerfDbClient::sendData(std::string hashed_id, std::string test_name, single_user_record_request.set_tag(tag); // setting configs - *(single_user_record_request.mutable_client_config()) = this->client_config_; - *(single_user_record_request.mutable_server_config()) = this->server_config_; + *(single_user_record_request.mutable_client_config()) = client_config_; + *(single_user_record_request.mutable_server_config()) = server_config_; Metrics* metrics = single_user_record_request.mutable_metrics(); // setting metrcs in data record request if (qps_ != DBL_MIN) { - metrics->set_qps(this->qps_); + metrics->set_qps(qps_); } if (qps_per_core_ != DBL_MIN) { - metrics->set_qps_per_core(this->qps_per_core_); + metrics->set_qps_per_core(qps_per_core_); } if (perc_lat_50_ != DBL_MIN) { - metrics->set_perc_lat_50(this->perc_lat_50_); + metrics->set_perc_lat_50(perc_lat_50_); } if (perc_lat_90_ != DBL_MIN) { - metrics->set_perc_lat_90(this->perc_lat_90_); + metrics->set_perc_lat_90(perc_lat_90_); } if (perc_lat_95_ != DBL_MIN) { - metrics->set_perc_lat_95(this->perc_lat_95_); + metrics->set_perc_lat_95(perc_lat_95_); } if (perc_lat_99_ != DBL_MIN) { - metrics->set_perc_lat_99(this->perc_lat_99_); + metrics->set_perc_lat_99(perc_lat_99_); } if (perc_lat_99_point_9_ != DBL_MIN) { - metrics->set_perc_lat_99_point_9(this->perc_lat_99_point_9_); + metrics->set_perc_lat_99_point_9(perc_lat_99_point_9_); } if (server_system_time_ != DBL_MIN) { - metrics->set_server_system_time(this->server_system_time_); + metrics->set_server_system_time(server_system_time_); } if (server_user_time_ != DBL_MIN) { - metrics->set_server_user_time(this->server_user_time_); + metrics->set_server_user_time(server_user_time_); } if (client_system_time_ != DBL_MIN) { - metrics->set_client_system_time(this->client_system_time_); + metrics->set_client_system_time(client_system_time_); } if (client_user_time_ != DBL_MIN) { - metrics->set_client_user_time(this->client_user_time_); + metrics->set_client_user_time(client_user_time_); } SingleUserRecordReply single_user_record_reply; From f1c6191149675a54f9384b73dac010f7a08149c0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 07:19:22 -0700 Subject: [PATCH 080/124] Ensure registry is shutdown --- src/core/surface/init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/surface/init.c b/src/core/surface/init.c index 9b9ecae27d2..3847ded28c8 100644 --- a/src/core/surface/init.c +++ b/src/core/surface/init.c @@ -92,6 +92,7 @@ void grpc_shutdown(void) { census_shutdown(); grpc_timers_global_destroy(); grpc_tracer_shutdown(); + grpc_resolver_registry_shutdown(); } gpr_mu_unlock(&g_init_mu); } From c8240676774f857fcd7b01988bd1242284419a8b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 07:32:52 -0700 Subject: [PATCH 081/124] Expand uri tests --- test/core/client_config/uri_parser_test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/core/client_config/uri_parser_test.c b/test/core/client_config/uri_parser_test.c index 287a9d1addb..e5f9017ce09 100644 --- a/test/core/client_config/uri_parser_test.c +++ b/test/core/client_config/uri_parser_test.c @@ -58,7 +58,12 @@ int main(int argc, char **argv) { test_succeeds("http://www.google.com", "http", "www.google.com", ""); test_succeeds("dns:///foo", "dns", "", "/foo"); test_succeeds("http://www.google.com:90", "http", "www.google.com:90", ""); + test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom"); + test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom"); test_fails("xyz"); test_fails("http://www.google.com?why-are-you-using-queries"); + test_fails("dns:foo.com#fragments-arent-supported-here"); + test_fails("http:?huh"); + test_fails("unix:#yeah-right"); return 0; } From d2cc45970b4681e214214199b9f52fc0e83cc9e9 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 07:50:47 -0700 Subject: [PATCH 082/124] Spam cleanup, properly shut down lb_policy --- src/core/channel/client_channel.c | 3 +++ src/core/client_config/lb_policies/pick_first.c | 12 ++++++++++-- src/core/client_config/subchannel.c | 4 +++- src/core/iomgr/fd_posix.c | 1 - 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 6815ec8718e..95afc0d2e37 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -436,6 +436,9 @@ static void cc_start_transport_op(grpc_channel_element *elem, GRPC_CHANNEL_FATAL_FAILURE); destroy_resolver = chand->resolver; chand->resolver = NULL; + if (chand->lb_policy != NULL) { + grpc_lb_policy_shutdown(chand->lb_policy); + } } if (!is_empty(op, sizeof(*op))) { diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index ffdae75b283..3967350a9b8 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -85,8 +85,16 @@ void pf_destroy(grpc_lb_policy *pol) { } void pf_shutdown(grpc_lb_policy *pol) { - /* pick_first_lb_policy *p = (pick_first_lb_policy*)pol; */ - abort(); + pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pending_pick *pp; + gpr_mu_lock(&p->mu); + while ((pp = p->pending_picks)) { + p->pending_picks = pp->next; + *pp->target = NULL; + grpc_iomgr_add_delayed_callback(pp->on_complete, 0); + gpr_free(pp); + } + gpr_mu_unlock(&p->mu); } void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index cde14b92223..05fd02fb0ab 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -562,6 +562,9 @@ static void on_alarm(void *arg, int iomgr_success) { grpc_subchannel *c = arg; gpr_mu_lock(&c->mu); c->have_alarm = 0; + if (c->disconnected) { + iomgr_success = 0; + } connectivity_state_changed_locked(c); gpr_mu_unlock(&c->mu); if (iomgr_success) { @@ -609,7 +612,6 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { static void connectivity_state_changed_locked(grpc_subchannel *c) { grpc_connectivity_state current = compute_connectivity_locked(c); - gpr_log(GPR_DEBUG, "SUBCHANNEL constate=%d", current); grpc_connectivity_state_set(&c->state_tracker, current); } diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index afecccae170..2075c43945d 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -159,7 +159,6 @@ void grpc_fd_global_shutdown(void) { grpc_fd *grpc_fd_create(int fd, const char *name) { grpc_fd *r = alloc_fd(fd); - gpr_log(GPR_DEBUG, "FD %d %p create", r->fd, r); grpc_iomgr_register_object(&r->iomgr_object, name); return r; } From 5d44c069e6870c0ddf26c1782f035c2835983e31 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 08:55:28 -0700 Subject: [PATCH 083/124] Refcounting fixes and debugging, empty batch stability fixes --- src/core/channel/client_channel.c | 72 ++++++++++++++++------ src/core/httpcli/httpcli.c | 2 +- src/core/security/client_auth_filter.c | 4 +- src/core/security/secure_transport_setup.c | 4 +- src/core/security/security_connector.c | 36 ++++++++--- src/core/security/security_connector.h | 23 +++++-- src/core/security/server_auth_filter.c | 4 +- src/core/security/server_secure_chttp2.c | 4 +- src/core/surface/secure_channel_create.c | 4 ++ 9 files changed, 109 insertions(+), 44 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 95afc0d2e37..a4de59efb1e 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -77,6 +77,7 @@ typedef struct { typedef enum { CALL_CREATED, + CALL_WAITING_FOR_SEND, CALL_WAITING_FOR_CONFIG, CALL_WAITING_FOR_PICK, CALL_WAITING_FOR_CALL, @@ -101,6 +102,9 @@ struct call_data { grpc_linked_mdelem details; }; +static grpc_iomgr_closure *merge_into_waiting_op(grpc_call_element *elem, + grpc_transport_stream_op *new_op) GRPC_MUST_USE_RESULT; + static void handle_op_after_cancellation(grpc_call_element *elem, grpc_transport_stream_op *op) { call_data *calld = elem->call_data; @@ -241,12 +245,13 @@ static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { &calld->picked_channel, &calld->async_setup_task); } -static void merge_into_waiting_op(grpc_call_element *elem, +static grpc_iomgr_closure *merge_into_waiting_op(grpc_call_element *elem, grpc_transport_stream_op *new_op) { call_data *calld = elem->call_data; + grpc_iomgr_closure *consumed_op = NULL; grpc_transport_stream_op *waiting_op = &calld->waiting_op; - GPR_ASSERT((waiting_op->send_ops == NULL) != (new_op->send_ops == NULL)); - GPR_ASSERT((waiting_op->recv_ops == NULL) != (new_op->recv_ops == NULL)); + GPR_ASSERT((waiting_op->send_ops == NULL) != (new_op->send_ops == NULL) || waiting_op->send_ops == NULL); + GPR_ASSERT((waiting_op->recv_ops == NULL) != (new_op->recv_ops == NULL) || waiting_op->recv_ops == NULL); if (new_op->send_ops != NULL) { waiting_op->send_ops = new_op->send_ops; waiting_op->is_last_send = new_op->is_last_send; @@ -257,13 +262,16 @@ static void merge_into_waiting_op(grpc_call_element *elem, waiting_op->recv_state = new_op->recv_state; waiting_op->on_done_recv = new_op->on_done_recv; } - if (waiting_op->on_consumed == NULL) { + if (new_op->on_consumed != NULL) { + if (waiting_op->on_consumed != NULL) { + consumed_op = waiting_op->on_consumed; + } waiting_op->on_consumed = new_op->on_consumed; - new_op->on_consumed = NULL; } if (new_op->cancel_with_status != GRPC_STATUS_OK) { waiting_op->cancel_with_status = new_op->cancel_with_status; } + return consumed_op; } static void perform_transport_stream_op(grpc_call_element *elem, @@ -274,6 +282,7 @@ static void perform_transport_stream_op(grpc_call_element *elem, grpc_subchannel_call *subchannel_call; grpc_lb_policy *lb_policy; grpc_transport_stream_op op2; + grpc_iomgr_closure *consumed_op = NULL; GPR_ASSERT(elem->filter == &grpc_client_channel_filter); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); @@ -289,6 +298,17 @@ static void perform_transport_stream_op(grpc_call_element *elem, gpr_mu_unlock(&calld->mu_state); handle_op_after_cancellation(elem, op); break; + case CALL_WAITING_FOR_SEND: + GPR_ASSERT(!continuation); + consumed_op = merge_into_waiting_op(elem, op); + if (!calld->waiting_op.send_ops && calld->waiting_op.cancel_with_status == GRPC_STATUS_OK) { + gpr_mu_unlock(&calld->mu_state); + break; + } + *op = calld->waiting_op; + memset(&calld->waiting_op, 0, sizeof(calld->waiting_op)); + continuation = 1; + /* fall through */ case CALL_WAITING_FOR_CONFIG: case CALL_WAITING_FOR_PICK: case CALL_WAITING_FOR_CALL: @@ -308,7 +328,7 @@ static void perform_transport_stream_op(grpc_call_element *elem, handle_op_after_cancellation(elem, op); handle_op_after_cancellation(elem, &op2); } else { - merge_into_waiting_op(elem, op); + consumed_op = merge_into_waiting_op(elem, op); gpr_mu_unlock(&calld->mu_state); if (op->on_consumed != NULL) { op->on_consumed->cb(op->on_consumed->cb_arg, 0); @@ -325,26 +345,37 @@ static void perform_transport_stream_op(grpc_call_element *elem, } else { calld->waiting_op = *op; - gpr_mu_lock(&chand->mu_config); - lb_policy = chand->lb_policy; - if (lb_policy) { - GRPC_LB_POLICY_REF(lb_policy, "pick"); - gpr_mu_unlock(&chand->mu_config); - calld->state = CALL_WAITING_FOR_PICK; + if (op->send_ops == NULL) { + /* need to have some send ops before we can select the + lb target */ + calld->state = CALL_WAITING_FOR_SEND; gpr_mu_unlock(&calld->mu_state); - - pick_target(lb_policy, calld); - - GRPC_LB_POLICY_UNREF(lb_policy, "pick"); } else { - calld->state = CALL_WAITING_FOR_CONFIG; - add_to_lb_policy_wait_queue_locked_state_config(elem); - gpr_mu_unlock(&chand->mu_config); - gpr_mu_unlock(&calld->mu_state); + gpr_mu_lock(&chand->mu_config); + lb_policy = chand->lb_policy; + if (lb_policy) { + GRPC_LB_POLICY_REF(lb_policy, "pick"); + gpr_mu_unlock(&chand->mu_config); + calld->state = CALL_WAITING_FOR_PICK; + gpr_mu_unlock(&calld->mu_state); + + pick_target(lb_policy, calld); + + GRPC_LB_POLICY_UNREF(lb_policy, "pick"); + } else { + calld->state = CALL_WAITING_FOR_CONFIG; + add_to_lb_policy_wait_queue_locked_state_config(elem); + gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&calld->mu_state); + } } } break; } + + if (consumed_op != NULL) { + consumed_op->cb(consumed_op->cb_arg, 1); + } } static void cc_start_transport_stream_op(grpc_call_element *elem, @@ -503,6 +534,7 @@ static void destroy_call_elem(grpc_call_element *elem) { case CALL_WAITING_FOR_PICK: case CALL_WAITING_FOR_CONFIG: case CALL_WAITING_FOR_CALL: + case CALL_WAITING_FOR_SEND: gpr_log(GPR_ERROR, "should never reach here"); abort(); break; diff --git a/src/core/httpcli/httpcli.c b/src/core/httpcli/httpcli.c index 914355a408b..3f5557e08ee 100644 --- a/src/core/httpcli/httpcli.c +++ b/src/core/httpcli/httpcli.c @@ -198,7 +198,7 @@ static void on_connected(void *arg, grpc_endpoint *tcp) { GRPC_SECURITY_OK); grpc_setup_secure_transport(&sc->base, tcp, on_secure_transport_setup_done, req); - grpc_security_connector_unref(&sc->base); + GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "httpcli"); } else { start_write(req); } diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index 5d04ec49b24..6816fbcfa1e 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -297,7 +297,7 @@ static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, /* initialize members */ GPR_ASSERT(sc->is_client_side); chand->security_connector = - (grpc_channel_security_connector *)grpc_security_connector_ref(sc); + (grpc_channel_security_connector *)GRPC_SECURITY_CONNECTOR_REF(sc, "client_auth_filter"); chand->md_ctx = metadata_context; chand->authority_string = grpc_mdstr_from_string(chand->md_ctx, ":authority"); chand->path_string = grpc_mdstr_from_string(chand->md_ctx, ":path"); @@ -310,7 +310,7 @@ static void destroy_channel_elem(grpc_channel_element *elem) { /* grab pointers to our data from the channel element */ channel_data *chand = elem->channel_data; grpc_channel_security_connector *ctx = chand->security_connector; - if (ctx != NULL) grpc_security_connector_unref(&ctx->base); + if (ctx != NULL) GRPC_SECURITY_CONNECTOR_UNREF(&ctx->base, "client_auth_filter"); if (chand->authority_string != NULL) { grpc_mdstr_unref(chand->authority_string); } diff --git a/src/core/security/secure_transport_setup.c b/src/core/security/secure_transport_setup.c index 1b39ab141ec..becc23bf7f5 100644 --- a/src/core/security/secure_transport_setup.c +++ b/src/core/security/secure_transport_setup.c @@ -74,7 +74,7 @@ static void secure_transport_setup_done(grpc_secure_transport_setup *s, if (s->handshaker != NULL) tsi_handshaker_destroy(s->handshaker); if (s->handshake_buffer != NULL) gpr_free(s->handshake_buffer); gpr_slice_buffer_destroy(&s->left_overs); - grpc_security_connector_unref(s->connector); + GRPC_SECURITY_CONNECTOR_UNREF(s->connector, "secure_transport_setup"); gpr_free(s); } @@ -275,7 +275,7 @@ void grpc_setup_secure_transport(grpc_security_connector *connector, secure_transport_setup_done(s, 0); return; } - s->connector = grpc_security_connector_ref(connector); + s->connector = GRPC_SECURITY_CONNECTOR_REF(connector, "secure_transport_setup"); s->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE; s->handshake_buffer = gpr_malloc(s->handshake_buffer_size); s->endpoint = nonsecure_endpoint; diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c index 34cb0395a24..f53e005d5bb 100644 --- a/src/core/security/security_connector.c +++ b/src/core/security/security_connector.c @@ -124,24 +124,42 @@ grpc_security_status grpc_channel_security_connector_check_call_host( return sc->check_call_host(sc, host, cb, user_data); } -void grpc_security_connector_unref(grpc_security_connector *sc) { - if (sc == NULL) return; - if (gpr_unref(&sc->refcount)) sc->vtable->destroy(sc); -} - -grpc_security_connector *grpc_security_connector_ref( - grpc_security_connector *sc) { +#ifdef GRPC_SECURITY_CONNECTOR_REFCOUNT_DEBUG +grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *sc, + const char *file, int line, + const char *reason) { + if (sc == NULL) return NULL; + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "SECURITY_CONNECTOR:%p ref %d -> %d %s", sc, (int)sc->refcount.count, + (int)sc->refcount.count + 1, reason); +#else +grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *sc) { if (sc == NULL) return NULL; +#endif gpr_ref(&sc->refcount); return sc; } +#ifdef GRPC_SECURITY_CONNECTOR_REFCOUNT_DEBUG +void grpc_security_connector_unref(grpc_security_connector *sc, const char *file, int line, + const char *reason) { + if (sc == NULL) return; + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "SECURITY_CONNECTOR:%p unref %d -> %d %s", sc, (int)sc->refcount.count, + (int)sc->refcount.count - 1, reason); +#else +void grpc_security_connector_unref(grpc_security_connector *sc) { + if (sc == NULL) return; +#endif + if (gpr_unref(&sc->refcount)) sc->vtable->destroy(sc); +} + static void connector_pointer_arg_destroy(void *p) { - grpc_security_connector_unref(p); + GRPC_SECURITY_CONNECTOR_UNREF(p, "connector_pointer_arg"); } static void *connector_pointer_arg_copy(void *p) { - return grpc_security_connector_ref(p); + return GRPC_SECURITY_CONNECTOR_REF(p, "connector_pointer_arg"); } grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) { diff --git a/src/core/security/security_connector.h b/src/core/security/security_connector.h index ee3057b43ba..f258b86b28e 100644 --- a/src/core/security/security_connector.h +++ b/src/core/security/security_connector.h @@ -80,12 +80,23 @@ struct grpc_security_connector { grpc_auth_context *auth_context; /* Populated after the peer is checked. */ }; -/* Increments the refcount. */ -grpc_security_connector *grpc_security_connector_ref( - grpc_security_connector *sc); - -/* Decrements the refcount and destroys the object if it reaches 0. */ -void grpc_security_connector_unref(grpc_security_connector *sc); +/* Refcounting. */ +#ifdef GRPC_SECURITY_CONNECTOR_REFCOUNT_DEBUG +#define GRPC_SECURITY_CONNECTOR_REF(p, r) \ + grpc_security_connector_ref((p), __FILE__, __LINE__, (r)) +#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) \ + grpc_security_connector_unref((p), __FILE__, __LINE__, (r)) +grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *policy, + const char *file, int line, + const char *reason); +void grpc_security_connector_unref(grpc_security_connector *policy, const char *file, + int line, const char *reason); +#else +#define GRPC_SECURITY_CONNECTOR_REF(p, r) grpc_security_connector_ref((p)) +#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) grpc_security_connector_unref((p)) +grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *policy); +void grpc_security_connector_unref(grpc_security_connector *policy); +#endif /* Handshake creation. */ grpc_security_status grpc_security_connector_create_handshaker( diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c index 5675c064023..51a4b32a669 100644 --- a/src/core/security/server_auth_filter.c +++ b/src/core/security/server_auth_filter.c @@ -107,14 +107,14 @@ static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, /* initialize members */ GPR_ASSERT(!sc->is_client_side); - chand->security_connector = grpc_security_connector_ref(sc); + chand->security_connector = GRPC_SECURITY_CONNECTOR_REF(sc, "server_auth_filter"); } /* Destructor for channel data */ static void destroy_channel_elem(grpc_channel_element *elem) { /* grab pointers to our data from the channel element */ channel_data *chand = elem->channel_data; - grpc_security_connector_unref(chand->security_connector); + GRPC_SECURITY_CONNECTOR_UNREF(chand->security_connector, "server_auth_filter"); } const grpc_channel_filter grpc_server_auth_filter = { diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c index 2e49e370f75..6a99324da6b 100644 --- a/src/core/security/server_secure_chttp2.c +++ b/src/core/security/server_secure_chttp2.c @@ -70,7 +70,7 @@ static void state_unref(grpc_server_secure_state *state) { gpr_mu_lock(&state->mu); gpr_mu_unlock(&state->mu); /* clean up */ - grpc_security_connector_unref(state->sc); + GRPC_SECURITY_CONNECTOR_UNREF(state->sc, "server"); gpr_free(state); } } @@ -220,7 +220,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr, /* Error path: cleanup and return */ error: if (sc) { - grpc_security_connector_unref(sc); + GRPC_SECURITY_CONNECTOR_UNREF(sc, "server"); } if (resolved) { grpc_resolved_addresses_destroy(resolved); diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index 1dd9e61d0fc..927c678c673 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -142,6 +142,7 @@ static void subchannel_factory_ref(grpc_subchannel_factory *scf) { static void subchannel_factory_unref(grpc_subchannel_factory *scf) { subchannel_factory *f = (subchannel_factory *)scf; if (gpr_unref(&f->refs)) { + GRPC_SECURITY_CONNECTOR_UNREF(&f->security_connector->base, "subchannel_factory"); grpc_channel_args_destroy(f->merge_args); grpc_mdctx_unref(f->mdctx); gpr_free(f); @@ -218,6 +219,7 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, gpr_ref_init(&f->refs, 1); grpc_mdctx_ref(mdctx); f->mdctx = mdctx; + GRPC_SECURITY_CONNECTOR_REF(&connector->base, "subchannel_factory"); f->security_connector = connector; f->merge_args = grpc_channel_args_copy(args_copy); resolver = grpc_resolver_create(target, &f->base); @@ -229,6 +231,8 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds, grpc_client_channel_set_resolver(grpc_channel_get_channel_stack(channel), resolver); GRPC_RESOLVER_UNREF(resolver, "create"); + grpc_subchannel_factory_unref(&f->base); + GRPC_SECURITY_CONNECTOR_UNREF(&connector->base, "channel_create"); grpc_channel_args_destroy(args_copy); if (new_args_from_connector != NULL) { From b9a46ae5d7044c6b436a33341135ead3f6fd7779 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 09:45:21 -0700 Subject: [PATCH 084/124] Fix a bug where cancelled calls can be stranded past disconnection --- src/core/channel/client_channel.c | 12 +++++++----- src/core/iomgr/tcp_client_posix.c | 2 -- src/core/surface/call.h | 2 ++ src/core/transport/transport_op_string.c | 7 +++++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index a4de59efb1e..5d9331d2c55 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -330,9 +330,6 @@ static void perform_transport_stream_op(grpc_call_element *elem, } else { consumed_op = merge_into_waiting_op(elem, op); gpr_mu_unlock(&calld->mu_state); - if (op->on_consumed != NULL) { - op->on_consumed->cb(op->on_consumed->cb_arg, 0); - } } break; } @@ -362,11 +359,16 @@ static void perform_transport_stream_op(grpc_call_element *elem, pick_target(lb_policy, calld); GRPC_LB_POLICY_UNREF(lb_policy, "pick"); - } else { + } else if (chand->resolver != NULL) { calld->state = CALL_WAITING_FOR_CONFIG; add_to_lb_policy_wait_queue_locked_state_config(elem); gpr_mu_unlock(&chand->mu_config); gpr_mu_unlock(&calld->mu_state); + } else { + calld->state = CALL_CANCELLED; + gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&calld->mu_state); + handle_op_after_cancellation(elem, op); } } } @@ -402,7 +404,7 @@ static void cc_on_config_changed(void *arg, int iomgr_success) { gpr_mu_lock(&chand->mu_config); old_lb_policy = chand->lb_policy; chand->lb_policy = lb_policy; - if (lb_policy != NULL) { + if (lb_policy != NULL || chand->resolver == NULL /* disconnected */) { wakeup_closures = chand->waiting_for_config_closures; chand->waiting_for_config_closures = NULL; } diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c index 20f833e28b9..d981aaf028e 100644 --- a/src/core/iomgr/tcp_client_posix.c +++ b/src/core/iomgr/tcp_client_posix.c @@ -166,13 +166,11 @@ static void on_writable(void *acp, int success) { finish: gpr_mu_lock(&ac->mu); - gpr_log(GPR_DEBUG, "ep=%p", ep); if (!ep) { grpc_pollset_set_del_fd(ac->interested_parties, ac->fd); grpc_fd_orphan(ac->fd, NULL, "tcp_client_orphan"); } done = (--ac->refs == 0); - gpr_log(GPR_DEBUG, "refs=%d", ac->refs); gpr_mu_unlock(&ac->mu); if (done) { gpr_mu_destroy(&ac->mu); diff --git a/src/core/surface/call.h b/src/core/surface/call.h index fb3662b50d3..8fa411048b3 100644 --- a/src/core/surface/call.h +++ b/src/core/surface/call.h @@ -94,6 +94,8 @@ grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq, void grpc_call_set_completion_queue(grpc_call *call, grpc_completion_queue *cq); grpc_completion_queue *grpc_call_get_completion_queue(grpc_call *call); +#define GRPC_CALL_REF_COUNT_DEBUG + #ifdef GRPC_CALL_REF_COUNT_DEBUG void grpc_call_internal_ref(grpc_call *call, const char *reason); void grpc_call_internal_unref(grpc_call *call, const char *reason, diff --git a/src/core/transport/transport_op_string.c b/src/core/transport/transport_op_string.c index 516aa9d4d8a..1ffdb5be94d 100644 --- a/src/core/transport/transport_op_string.c +++ b/src/core/transport/transport_op_string.c @@ -146,6 +146,13 @@ char *grpc_transport_stream_op_string(grpc_transport_stream_op *op) { gpr_strvec_add(&b, tmp); } + if (op->on_consumed != NULL) { + if (!first) gpr_strvec_add(&b, gpr_strdup(" ")); + first = 0; + gpr_asprintf(&tmp, "ON_CONSUMED:%p", op->on_consumed); + gpr_strvec_add(&b, tmp); + } + out = gpr_strvec_flatten(&b, NULL); gpr_strvec_destroy(&b); From 740aac1a4bb10d58cf7ca411e5a1205e5b0f339f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 10:03:50 -0700 Subject: [PATCH 085/124] Fix an lb_policy leak --- src/core/client_config/lb_policies/pick_first.c | 1 + src/core/surface/call.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index 3967350a9b8..ec2a45a5728 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -192,6 +192,7 @@ loop: grpc_iomgr_add_delayed_callback(pp->on_complete, 1); gpr_free(pp); } + unref = 1; } else { p->checking_subchannel %= p->num_subchannels; p->checking_connectivity = grpc_subchannel_check_connectivity( diff --git a/src/core/surface/call.h b/src/core/surface/call.h index 8fa411048b3..fb3662b50d3 100644 --- a/src/core/surface/call.h +++ b/src/core/surface/call.h @@ -94,8 +94,6 @@ grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq, void grpc_call_set_completion_queue(grpc_call *call, grpc_completion_queue *cq); grpc_completion_queue *grpc_call_get_completion_queue(grpc_call *call); -#define GRPC_CALL_REF_COUNT_DEBUG - #ifdef GRPC_CALL_REF_COUNT_DEBUG void grpc_call_internal_ref(grpc_call *call, const char *reason); void grpc_call_internal_unref(grpc_call *call, const char *reason, From a9a3362f5cd460d7dc08bf99f94c4fb98865a719 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 10:35:56 -0700 Subject: [PATCH 086/124] Spam cleanup --- src/core/client_config/subchannel.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 05fd02fb0ab..93c703e7c44 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -179,7 +179,6 @@ static void subchannel_destroy(grpc_subchannel *c); static void connection_destroy(connection *c) { GPR_ASSERT(c->refs == 0); - gpr_log(GPR_DEBUG, "CONNECTION_DESTROY %p", c); grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CONNECTION(c)); gpr_free(c); } @@ -433,8 +432,6 @@ static void on_state_changed(void *p, int iomgr_success) { goto done; } - gpr_log(GPR_DEBUG, "TRANSPORT STATE: %d", sw->connectivity_state); - switch (sw->connectivity_state) { case GRPC_CHANNEL_CONNECTING: case GRPC_CHANNEL_READY: From 2a6e35677906200e27f20127882efe1028873a42 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 10:36:06 -0700 Subject: [PATCH 087/124] Spam cleanup --- src/core/surface/server.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/surface/server.c b/src/core/surface/server.c index c883d08a02e..f29d47c17c4 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -266,7 +266,6 @@ static void send_shutdown(grpc_channel *channel, int send_goaway, grpc_channel_element *elem; memset(&op, 0, sizeof(op)); - gpr_log(GPR_DEBUG, "send_goaway:%d", send_goaway); op.send_goaway = send_goaway; sc = gpr_malloc(sizeof(*sc)); sc->slice = gpr_slice_from_copied_string("Server shutdown"); From 17be5dc7969f21d99a40cb116f84067eee54923b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 10:36:27 -0700 Subject: [PATCH 088/124] Fix a list management bug exposed by new locking scheme in client_channel --- src/core/transport/chttp2/internal.h | 8 ++++++ src/core/transport/chttp2/stream_lists.c | 18 +++++++++++++ src/core/transport/chttp2_transport.c | 34 +++++++++++++++--------- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h index c8c46f0e544..7f98a5bd711 100644 --- a/src/core/transport/chttp2/internal.h +++ b/src/core/transport/chttp2/internal.h @@ -63,6 +63,7 @@ typedef enum { GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE, GRPC_CHTTP2_LIST_PARSING_SEEN, GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING, + GRPC_CHTTP2_LIST_CANCELLED_WAITING_FOR_WRITING, GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED, /** streams that are waiting to start because there are too many concurrent streams on the connection */ @@ -526,6 +527,13 @@ int grpc_chttp2_list_pop_closed_waiting_for_parsing( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global **stream_global); +void grpc_chttp2_list_add_cancelled_waiting_for_writing( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global *stream_global); +int grpc_chttp2_list_pop_cancelled_waiting_for_writing( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global **stream_global); + void grpc_chttp2_list_add_read_write_state_changed( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global); diff --git a/src/core/transport/chttp2/stream_lists.c b/src/core/transport/chttp2/stream_lists.c index c6ba12fca87..f04e763387c 100644 --- a/src/core/transport/chttp2/stream_lists.c +++ b/src/core/transport/chttp2/stream_lists.c @@ -282,6 +282,24 @@ int grpc_chttp2_list_pop_closed_waiting_for_parsing( return r; } +void grpc_chttp2_list_add_cancelled_waiting_for_writing( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global *stream_global) { + stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global), + STREAM_FROM_GLOBAL(stream_global), + GRPC_CHTTP2_LIST_CANCELLED_WAITING_FOR_WRITING); +} + +int grpc_chttp2_list_pop_cancelled_waiting_for_writing( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global **stream_global) { + grpc_chttp2_stream *stream; + int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, + GRPC_CHTTP2_LIST_CANCELLED_WAITING_FOR_WRITING); + *stream_global = &stream->global; + return r; +} + void grpc_chttp2_list_add_incoming_window_updated( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global) { diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 4bcb317fe79..a7f9af5c0c4 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -765,21 +765,31 @@ static void unlock_check_read_write_state(grpc_chttp2_transport *t) { } } + if (!t->writing_active) { + while (grpc_chttp2_list_pop_cancelled_waiting_for_writing(transport_global, &stream_global)) { + grpc_chttp2_list_add_read_write_state_changed(transport_global, stream_global); + } + } + while (grpc_chttp2_list_pop_read_write_state_changed(transport_global, &stream_global)) { if (stream_global->cancelled) { - stream_global->write_state = GRPC_WRITE_STATE_SENT_CLOSE; - stream_global->read_closed = 1; - if (!stream_global->published_cancelled) { - char buffer[GPR_LTOA_MIN_BUFSIZE]; - gpr_ltoa(stream_global->cancelled_status, buffer); - grpc_chttp2_incoming_metadata_buffer_add( - &stream_global->incoming_metadata, - grpc_mdelem_from_strings(t->metadata_context, "grpc-status", - buffer)); - grpc_chttp2_incoming_metadata_buffer_place_metadata_batch_into( - &stream_global->incoming_metadata, &stream_global->incoming_sopb); - stream_global->published_cancelled = 1; + if (t->writing_active && stream_global->write_state != GRPC_WRITE_STATE_SENT_CLOSE) { + grpc_chttp2_list_add_cancelled_waiting_for_writing(transport_global, stream_global); + } else { + stream_global->write_state = GRPC_WRITE_STATE_SENT_CLOSE; + stream_global->read_closed = 1; + if (!stream_global->published_cancelled) { + char buffer[GPR_LTOA_MIN_BUFSIZE]; + gpr_ltoa(stream_global->cancelled_status, buffer); + grpc_chttp2_incoming_metadata_buffer_add( + &stream_global->incoming_metadata, + grpc_mdelem_from_strings(t->metadata_context, "grpc-status", + buffer)); + grpc_chttp2_incoming_metadata_buffer_place_metadata_batch_into( + &stream_global->incoming_metadata, &stream_global->incoming_sopb); + stream_global->published_cancelled = 1; + } } } if (stream_global->write_state == GRPC_WRITE_STATE_SENT_CLOSE && From b3671531159b7bbce54c4c3ee4895380a4c968fc Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 10:37:40 -0700 Subject: [PATCH 089/124] clang-format changed files --- src/core/channel/client_channel.c | 20 ++++++----- .../client_config/lb_policies/pick_first.c | 2 +- src/core/security/client_auth_filter.c | 6 ++-- src/core/security/secure_transport_setup.c | 8 +++-- src/core/security/security_connector.c | 35 ++++++++++--------- src/core/security/security_connector.h | 24 +++++++------ src/core/security/server_auth_filter.c | 6 ++-- src/core/surface/secure_channel_create.c | 3 +- src/core/transport/chttp2/stream_lists.c | 4 ++- src/core/transport/chttp2_transport.c | 12 ++++--- 10 files changed, 71 insertions(+), 49 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 5d9331d2c55..384724d3158 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -102,8 +102,9 @@ struct call_data { grpc_linked_mdelem details; }; -static grpc_iomgr_closure *merge_into_waiting_op(grpc_call_element *elem, - grpc_transport_stream_op *new_op) GRPC_MUST_USE_RESULT; +static grpc_iomgr_closure *merge_into_waiting_op( + grpc_call_element *elem, + grpc_transport_stream_op *new_op) GRPC_MUST_USE_RESULT; static void handle_op_after_cancellation(grpc_call_element *elem, grpc_transport_stream_op *op) { @@ -245,13 +246,15 @@ static void pick_target(grpc_lb_policy *lb_policy, call_data *calld) { &calld->picked_channel, &calld->async_setup_task); } -static grpc_iomgr_closure *merge_into_waiting_op(grpc_call_element *elem, - grpc_transport_stream_op *new_op) { +static grpc_iomgr_closure *merge_into_waiting_op( + grpc_call_element *elem, grpc_transport_stream_op *new_op) { call_data *calld = elem->call_data; grpc_iomgr_closure *consumed_op = NULL; grpc_transport_stream_op *waiting_op = &calld->waiting_op; - GPR_ASSERT((waiting_op->send_ops == NULL) != (new_op->send_ops == NULL) || waiting_op->send_ops == NULL); - GPR_ASSERT((waiting_op->recv_ops == NULL) != (new_op->recv_ops == NULL) || waiting_op->recv_ops == NULL); + GPR_ASSERT((waiting_op->send_ops == NULL) != (new_op->send_ops == NULL) || + waiting_op->send_ops == NULL); + GPR_ASSERT((waiting_op->recv_ops == NULL) != (new_op->recv_ops == NULL) || + waiting_op->recv_ops == NULL); if (new_op->send_ops != NULL) { waiting_op->send_ops = new_op->send_ops; waiting_op->is_last_send = new_op->is_last_send; @@ -301,14 +304,15 @@ static void perform_transport_stream_op(grpc_call_element *elem, case CALL_WAITING_FOR_SEND: GPR_ASSERT(!continuation); consumed_op = merge_into_waiting_op(elem, op); - if (!calld->waiting_op.send_ops && calld->waiting_op.cancel_with_status == GRPC_STATUS_OK) { + if (!calld->waiting_op.send_ops && + calld->waiting_op.cancel_with_status == GRPC_STATUS_OK) { gpr_mu_unlock(&calld->mu_state); break; } *op = calld->waiting_op; memset(&calld->waiting_op, 0, sizeof(calld->waiting_op)); continuation = 1; - /* fall through */ + /* fall through */ case CALL_WAITING_FOR_CONFIG: case CALL_WAITING_FOR_PICK: case CALL_WAITING_FOR_CALL: diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index ec2a45a5728..3d57e3136a4 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -85,7 +85,7 @@ void pf_destroy(grpc_lb_policy *pol) { } void pf_shutdown(grpc_lb_policy *pol) { - pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pick_first_lb_policy *p = (pick_first_lb_policy *)pol; pending_pick *pp; gpr_mu_lock(&p->mu); while ((pp = p->pending_picks)) { diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index 6816fbcfa1e..f8d18d9b171 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -297,7 +297,8 @@ static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, /* initialize members */ GPR_ASSERT(sc->is_client_side); chand->security_connector = - (grpc_channel_security_connector *)GRPC_SECURITY_CONNECTOR_REF(sc, "client_auth_filter"); + (grpc_channel_security_connector *)GRPC_SECURITY_CONNECTOR_REF( + sc, "client_auth_filter"); chand->md_ctx = metadata_context; chand->authority_string = grpc_mdstr_from_string(chand->md_ctx, ":authority"); chand->path_string = grpc_mdstr_from_string(chand->md_ctx, ":path"); @@ -310,7 +311,8 @@ static void destroy_channel_elem(grpc_channel_element *elem) { /* grab pointers to our data from the channel element */ channel_data *chand = elem->channel_data; grpc_channel_security_connector *ctx = chand->security_connector; - if (ctx != NULL) GRPC_SECURITY_CONNECTOR_UNREF(&ctx->base, "client_auth_filter"); + if (ctx != NULL) + GRPC_SECURITY_CONNECTOR_UNREF(&ctx->base, "client_auth_filter"); if (chand->authority_string != NULL) { grpc_mdstr_unref(chand->authority_string); } diff --git a/src/core/security/secure_transport_setup.c b/src/core/security/secure_transport_setup.c index becc23bf7f5..731b382f091 100644 --- a/src/core/security/secure_transport_setup.c +++ b/src/core/security/secure_transport_setup.c @@ -234,8 +234,9 @@ static void on_handshake_data_received_from_peer( gpr_slice_split_tail(&slices[i], consumed_slice_size)); gpr_slice_unref(slices[i]); /* split_tail above increments refcount. */ } - gpr_slice_buffer_addn(&s->left_overs, &slices[i + 1], - num_left_overs - (size_t)has_left_overs_in_current_slice); + gpr_slice_buffer_addn( + &s->left_overs, &slices[i + 1], + num_left_overs - (size_t)has_left_overs_in_current_slice); check_peer(s); } @@ -275,7 +276,8 @@ void grpc_setup_secure_transport(grpc_security_connector *connector, secure_transport_setup_done(s, 0); return; } - s->connector = GRPC_SECURITY_CONNECTOR_REF(connector, "secure_transport_setup"); + s->connector = + GRPC_SECURITY_CONNECTOR_REF(connector, "secure_transport_setup"); s->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE; s->handshake_buffer = gpr_malloc(s->handshake_buffer_size); s->endpoint = nonsecure_endpoint; diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c index f53e005d5bb..f6e423eb279 100644 --- a/src/core/security/security_connector.c +++ b/src/core/security/security_connector.c @@ -84,12 +84,12 @@ static const char *ssl_cipher_suites(void) { /* -- Common methods. -- */ /* Returns the first property with that name. */ -const tsi_peer_property *tsi_peer_get_property_by_name( - const tsi_peer *peer, const char *name) { +const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer, + const char *name) { size_t i; if (peer == NULL) return NULL; for (i = 0; i < peer->property_count; i++) { - const tsi_peer_property* property = &peer->properties[i]; + const tsi_peer_property *property = &peer->properties[i]; if (name == NULL && property->name == NULL) { return property; } @@ -125,15 +125,16 @@ grpc_security_status grpc_channel_security_connector_check_call_host( } #ifdef GRPC_SECURITY_CONNECTOR_REFCOUNT_DEBUG -grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *sc, - const char *file, int line, - const char *reason) { +grpc_security_connector *grpc_security_connector_ref( + grpc_security_connector *sc, const char *file, int line, + const char *reason) { if (sc == NULL) return NULL; gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "SECURITY_CONNECTOR:%p ref %d -> %d %s", sc, (int)sc->refcount.count, - (int)sc->refcount.count + 1, reason); + "SECURITY_CONNECTOR:%p ref %d -> %d %s", sc, + (int)sc->refcount.count, (int)sc->refcount.count + 1, reason); #else -grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *sc) { +grpc_security_connector *grpc_security_connector_ref( + grpc_security_connector *sc) { if (sc == NULL) return NULL; #endif gpr_ref(&sc->refcount); @@ -141,12 +142,13 @@ grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *sc } #ifdef GRPC_SECURITY_CONNECTOR_REFCOUNT_DEBUG -void grpc_security_connector_unref(grpc_security_connector *sc, const char *file, int line, - const char *reason) { +void grpc_security_connector_unref(grpc_security_connector *sc, + const char *file, int line, + const char *reason) { if (sc == NULL) return; gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "SECURITY_CONNECTOR:%p unref %d -> %d %s", sc, (int)sc->refcount.count, - (int)sc->refcount.count - 1, reason); + "SECURITY_CONNECTOR:%p unref %d -> %d %s", sc, + (int)sc->refcount.count, (int)sc->refcount.count - 1, reason); #else void grpc_security_connector_unref(grpc_security_connector *sc) { if (sc == NULL) return; @@ -598,7 +600,8 @@ grpc_security_status grpc_ssl_channel_security_connector_create( config->pem_private_key, config->pem_private_key_size, config->pem_cert_chain, config->pem_cert_chain_size, pem_root_certs, pem_root_certs_size, ssl_cipher_suites(), alpn_protocol_strings, - alpn_protocol_string_lengths, (uint16_t)num_alpn_protocols, &c->handshaker_factory); + alpn_protocol_string_lengths, (uint16_t)num_alpn_protocols, + &c->handshaker_factory); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", tsi_result_to_string(result)); @@ -651,8 +654,8 @@ grpc_security_status grpc_ssl_server_security_connector_create( (const unsigned char **)config->pem_cert_chains, config->pem_cert_chains_sizes, config->num_key_cert_pairs, config->pem_root_certs, config->pem_root_certs_size, ssl_cipher_suites(), - alpn_protocol_strings, alpn_protocol_string_lengths, (uint16_t)num_alpn_protocols, - &c->handshaker_factory); + alpn_protocol_strings, alpn_protocol_string_lengths, + (uint16_t)num_alpn_protocols, &c->handshaker_factory); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", tsi_result_to_string(result)); diff --git a/src/core/security/security_connector.h b/src/core/security/security_connector.h index f258b86b28e..a4c723f0260 100644 --- a/src/core/security/security_connector.h +++ b/src/core/security/security_connector.h @@ -86,15 +86,17 @@ struct grpc_security_connector { grpc_security_connector_ref((p), __FILE__, __LINE__, (r)) #define GRPC_SECURITY_CONNECTOR_UNREF(p, r) \ grpc_security_connector_unref((p), __FILE__, __LINE__, (r)) -grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *policy, - const char *file, int line, - const char *reason); -void grpc_security_connector_unref(grpc_security_connector *policy, const char *file, - int line, const char *reason); +grpc_security_connector *grpc_security_connector_ref( + grpc_security_connector *policy, const char *file, int line, + const char *reason); +void grpc_security_connector_unref(grpc_security_connector *policy, + const char *file, int line, + const char *reason); #else #define GRPC_SECURITY_CONNECTOR_REF(p, r) grpc_security_connector_ref((p)) #define GRPC_SECURITY_CONNECTOR_UNREF(p, r) grpc_security_connector_unref((p)) -grpc_security_connector *grpc_security_connector_ref(grpc_security_connector *policy); +grpc_security_connector *grpc_security_connector_ref( + grpc_security_connector *policy); void grpc_security_connector_unref(grpc_security_connector *policy); #endif @@ -183,9 +185,9 @@ typedef struct { specific error code otherwise. */ grpc_security_status grpc_ssl_channel_security_connector_create( - grpc_credentials *request_metadata_creds, - const grpc_ssl_config *config, const char *target_name, - const char *overridden_target_name, grpc_channel_security_connector **sc); + grpc_credentials *request_metadata_creds, const grpc_ssl_config *config, + const char *target_name, const char *overridden_target_name, + grpc_channel_security_connector **sc); /* Gets the default ssl roots. */ size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs); @@ -211,8 +213,8 @@ grpc_security_status grpc_ssl_server_security_connector_create( const grpc_ssl_server_config *config, grpc_security_connector **sc); /* Util. */ -const tsi_peer_property *tsi_peer_get_property_by_name( - const tsi_peer *peer, const char *name); +const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer, + const char *name); /* Exposed for testing only. */ grpc_auth_context *tsi_ssl_peer_to_auth_context(const tsi_peer *peer); diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c index 51a4b32a669..10eef6d2378 100644 --- a/src/core/security/server_auth_filter.c +++ b/src/core/security/server_auth_filter.c @@ -107,14 +107,16 @@ static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, /* initialize members */ GPR_ASSERT(!sc->is_client_side); - chand->security_connector = GRPC_SECURITY_CONNECTOR_REF(sc, "server_auth_filter"); + chand->security_connector = + GRPC_SECURITY_CONNECTOR_REF(sc, "server_auth_filter"); } /* Destructor for channel data */ static void destroy_channel_elem(grpc_channel_element *elem) { /* grab pointers to our data from the channel element */ channel_data *chand = elem->channel_data; - GRPC_SECURITY_CONNECTOR_UNREF(chand->security_connector, "server_auth_filter"); + GRPC_SECURITY_CONNECTOR_UNREF(chand->security_connector, + "server_auth_filter"); } const grpc_channel_filter grpc_server_auth_filter = { diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index 927c678c673..76fc862621f 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -142,7 +142,8 @@ static void subchannel_factory_ref(grpc_subchannel_factory *scf) { static void subchannel_factory_unref(grpc_subchannel_factory *scf) { subchannel_factory *f = (subchannel_factory *)scf; if (gpr_unref(&f->refs)) { - GRPC_SECURITY_CONNECTOR_UNREF(&f->security_connector->base, "subchannel_factory"); + GRPC_SECURITY_CONNECTOR_UNREF(&f->security_connector->base, + "subchannel_factory"); grpc_channel_args_destroy(f->merge_args); grpc_mdctx_unref(f->mdctx); gpr_free(f); diff --git a/src/core/transport/chttp2/stream_lists.c b/src/core/transport/chttp2/stream_lists.c index f04e763387c..85691b32d26 100644 --- a/src/core/transport/chttp2/stream_lists.c +++ b/src/core/transport/chttp2/stream_lists.c @@ -222,7 +222,9 @@ int grpc_chttp2_list_pop_writable_window_update_stream( void grpc_chttp2_list_remove_writable_window_update_stream( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global) { - stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global), STREAM_FROM_GLOBAL(stream_global), GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE); + stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global), + STREAM_FROM_GLOBAL(stream_global), + GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE); } void grpc_chttp2_list_add_parsing_seen_stream( diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index a7f9af5c0c4..0a7b8f5bf9a 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -766,16 +766,20 @@ static void unlock_check_read_write_state(grpc_chttp2_transport *t) { } if (!t->writing_active) { - while (grpc_chttp2_list_pop_cancelled_waiting_for_writing(transport_global, &stream_global)) { - grpc_chttp2_list_add_read_write_state_changed(transport_global, stream_global); + while (grpc_chttp2_list_pop_cancelled_waiting_for_writing(transport_global, + &stream_global)) { + grpc_chttp2_list_add_read_write_state_changed(transport_global, + stream_global); } } while (grpc_chttp2_list_pop_read_write_state_changed(transport_global, &stream_global)) { if (stream_global->cancelled) { - if (t->writing_active && stream_global->write_state != GRPC_WRITE_STATE_SENT_CLOSE) { - grpc_chttp2_list_add_cancelled_waiting_for_writing(transport_global, stream_global); + if (t->writing_active && + stream_global->write_state != GRPC_WRITE_STATE_SENT_CLOSE) { + grpc_chttp2_list_add_cancelled_waiting_for_writing(transport_global, + stream_global); } else { stream_global->write_state = GRPC_WRITE_STATE_SENT_CLOSE; stream_global->read_closed = 1; From ae65f1a212d1de208ed70ca0aa48be7bbc2d0ae5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 11:23:59 -0700 Subject: [PATCH 090/124] Remove random includes of windows.h Instead, include a stanza in port_platform.h that: - gets windows.h included - defines things that we needs to define - tries to respect applications configurations by leaving things as untouched as possible --- include/grpc/support/atm_win32.h | 2 -- include/grpc/support/log_win32.h | 2 -- include/grpc/support/port_platform.h | 32 ++++++++++++++++++++++++++++ include/grpc/support/sync_win32.h | 2 -- src/core/iomgr/iocp_windows.h | 1 - src/core/iomgr/pollset_windows.h | 1 - src/core/iomgr/sockaddr_win32.h | 2 +- src/core/iomgr/socket_windows.h | 3 ++- src/core/support/cpu_windows.c | 1 - src/core/support/string_win32.c | 1 - src/core/support/string_win32.h | 2 -- src/core/support/sync_win32.c | 3 --- src/core/support/thd_win32.c | 1 - src/core/support/time_win32.c | 1 - 14 files changed, 35 insertions(+), 19 deletions(-) diff --git a/include/grpc/support/atm_win32.h b/include/grpc/support/atm_win32.h index dcba4d433d5..da99021c24b 100644 --- a/include/grpc/support/atm_win32.h +++ b/include/grpc/support/atm_win32.h @@ -37,8 +37,6 @@ /* Win32 variant of atm_platform.h */ #include -#include - typedef gpr_intptr gpr_atm; #define gpr_atm_full_barrier MemoryBarrier diff --git a/include/grpc/support/log_win32.h b/include/grpc/support/log_win32.h index ad0edcdb89f..595a81a5af9 100644 --- a/include/grpc/support/log_win32.h +++ b/include/grpc/support/log_win32.h @@ -34,8 +34,6 @@ #ifndef GRPC_SUPPORT_LOG_WIN32_H #define GRPC_SUPPORT_LOG_WIN32_H -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 4fbce9c8d9b..d3cfee113d1 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -34,6 +34,38 @@ #ifndef GRPC_SUPPORT_PORT_PLATFORM_H #define GRPC_SUPPORT_PORT_PLATFORM_H +/* Get windows.h included everywhere (we need it) */ +#if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32) +#ifndef WIN32_LEAN_AND_MEAN +#define GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED +#define WIN32_LEAN_AND_MEAN +#endif /* WIN32_LEAN_AND_MEAN */ + +#ifndef NOMINMAX +#define GRPC_NOMINMX_WAS_NOT_DEFINED +#define NOMINMAX +#endif /* NOMINMAX */ + +#if defined(_WIN32_WINNT) +#if _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif /* _WIN32_WINNT < 0x0600 */ +#endif /* defined(_WIN32_WINNT) */ + +#include + +#ifdef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED +#undef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED +#undef WIN32_LEAN_AND_MEAN +#endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */ + +#ifdef GRPC_NOMINMAX_WAS_NOT_DEFINED +#undef GRPC_NOMINMAX_WAS_NOT_DEFINED +#undef NOMINMAX +#endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */ +#endif /* defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32) */ + /* Override this file with one for your platform if you need to redefine things. */ diff --git a/include/grpc/support/sync_win32.h b/include/grpc/support/sync_win32.h index cb2a8663a05..66b9af9074b 100644 --- a/include/grpc/support/sync_win32.h +++ b/include/grpc/support/sync_win32.h @@ -36,8 +36,6 @@ #include -#include - typedef struct { CRITICAL_SECTION cs; /* Not an SRWLock until Vista is unsupported */ int locked; diff --git a/src/core/iomgr/iocp_windows.h b/src/core/iomgr/iocp_windows.h index 4503fdd55ee..9df6476917f 100644 --- a/src/core/iomgr/iocp_windows.h +++ b/src/core/iomgr/iocp_windows.h @@ -34,7 +34,6 @@ #ifndef GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H #define GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H -#include #include #include "src/core/iomgr/socket_windows.h" diff --git a/src/core/iomgr/pollset_windows.h b/src/core/iomgr/pollset_windows.h index 57a29079266..c9b8d3f3749 100644 --- a/src/core/iomgr/pollset_windows.h +++ b/src/core/iomgr/pollset_windows.h @@ -34,7 +34,6 @@ #ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H #define GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H -#include #include #include "src/core/iomgr/socket_windows.h" diff --git a/src/core/iomgr/sockaddr_win32.h b/src/core/iomgr/sockaddr_win32.h index c0385ea6148..be55db805aa 100644 --- a/src/core/iomgr/sockaddr_win32.h +++ b/src/core/iomgr/sockaddr_win32.h @@ -34,8 +34,8 @@ #ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H #define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H -#include #include +#include #include #ifdef __MINGW32__ diff --git a/src/core/iomgr/socket_windows.h b/src/core/iomgr/socket_windows.h index 7080919af09..f7b969eb5ea 100644 --- a/src/core/iomgr/socket_windows.h +++ b/src/core/iomgr/socket_windows.h @@ -34,7 +34,8 @@ #ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H #define GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H -#include +#include +#include #include #include diff --git a/src/core/support/cpu_windows.c b/src/core/support/cpu_windows.c index 107a7b85f00..ce32eb0a9d6 100644 --- a/src/core/support/cpu_windows.c +++ b/src/core/support/cpu_windows.c @@ -34,7 +34,6 @@ #include #ifdef GPR_WIN32 -#include #include unsigned gpr_cpu_num_cores(void) { diff --git a/src/core/support/string_win32.c b/src/core/support/string_win32.c index 6d1d6337a93..27b9f3637a6 100644 --- a/src/core/support/string_win32.c +++ b/src/core/support/string_win32.c @@ -37,7 +37,6 @@ #ifdef GPR_WIN32 -#include #include #include #include diff --git a/src/core/support/string_win32.h b/src/core/support/string_win32.h index 0bc3247d9da..1260aa55c16 100644 --- a/src/core/support/string_win32.h +++ b/src/core/support/string_win32.h @@ -38,8 +38,6 @@ #ifdef GPR_WIN32 -#include - /* These allocate new strings using gpr_malloc to convert from and to utf-8. */ LPTSTR gpr_char_to_tchar(LPCSTR input); LPSTR gpr_tchar_to_char(LPCTSTR input); diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c index cc31d9b052d..72f39f8d464 100644 --- a/src/core/support/sync_win32.c +++ b/src/core/support/sync_win32.c @@ -37,9 +37,6 @@ #ifdef GPR_WIN32 -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#include #include #include #include diff --git a/src/core/support/thd_win32.c b/src/core/support/thd_win32.c index 3cc798293ac..4fa3907444f 100644 --- a/src/core/support/thd_win32.c +++ b/src/core/support/thd_win32.c @@ -37,7 +37,6 @@ #ifdef GPR_WIN32 -#include #include #include #include diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c index f4443b5c2d7..9db267c01b0 100644 --- a/src/core/support/time_win32.c +++ b/src/core/support/time_win32.c @@ -39,7 +39,6 @@ #include #include -#include gpr_timespec gpr_now(void) { gpr_timespec now_tv; From 62b1473a0d49cbbcfa16b15109cf1597673a3d65 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 11:28:41 -0700 Subject: [PATCH 091/124] Add missing unlock --- src/core/channel/client_channel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 384724d3158..61fc4222d1f 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -202,6 +202,7 @@ static void started_call(void *arg, int iomgr_success) { } } else { GPR_ASSERT(calld->state == CALL_CANCELLED); + gpr_mu_unlock(&calld->mu_state); } } From 2e9dc506e70b351c341ffac31abcd9d2de858172 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 11:31:07 -0700 Subject: [PATCH 092/124] Simplify check --- src/core/channel/client_channel.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 61fc4222d1f..1eab87d7149 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -252,10 +252,8 @@ static grpc_iomgr_closure *merge_into_waiting_op( call_data *calld = elem->call_data; grpc_iomgr_closure *consumed_op = NULL; grpc_transport_stream_op *waiting_op = &calld->waiting_op; - GPR_ASSERT((waiting_op->send_ops == NULL) != (new_op->send_ops == NULL) || - waiting_op->send_ops == NULL); - GPR_ASSERT((waiting_op->recv_ops == NULL) != (new_op->recv_ops == NULL) || - waiting_op->recv_ops == NULL); + GPR_ASSERT((waiting_op->send_ops != NULL) + (new_op->send_ops != NULL) <= 1); + GPR_ASSERT((waiting_op->recv_ops != NULL) + (new_op->recv_ops != NULL) <= 1); if (new_op->send_ops != NULL) { waiting_op->send_ops = new_op->send_ops; waiting_op->is_last_send = new_op->is_last_send; From 684d8f600d751c226ea70b0db92bc7d50c595bbf Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 11:31:48 -0700 Subject: [PATCH 093/124] Change capitalization --- src/core/iomgr/socket_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/iomgr/socket_windows.h b/src/core/iomgr/socket_windows.h index f7b969eb5ea..346fde8eddb 100644 --- a/src/core/iomgr/socket_windows.h +++ b/src/core/iomgr/socket_windows.h @@ -35,7 +35,7 @@ #define GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H #include -#include +#include #include #include From 560619958524aac022b54eb9dec51071684651ed Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 1 Jul 2015 13:39:48 -0700 Subject: [PATCH 094/124] Delete spare contexts lying around at the end of the test to avoid showing up as memory leaks Also reduce the rate of the openloop test - this may be an issue with sanitizers particularly because of issue #2278 --- test/cpp/qps/client_async.cc | 9 +++++++++ test/cpp/qps/qps_test_openloop.cc | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 8c8d927d15f..7c89a35ee7e 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -199,6 +199,15 @@ class AsyncClient : public Client { delete ClientRpcContext::detag(got_tag); } } + // Now clear out all the pre-allocated idle contexts + for (int ch = 0; ch < channel_count_; ch++) { + if (!contexts_[ch].empty()) { + // Get an idle context from the front of the list + auto* ctx = *(contexts_[ch].begin()); + contexts_[ch].pop_front(); + delete ctx; + } + } } bool ThreadFunc(Histogram* histogram, diff --git a/test/cpp/qps/qps_test_openloop.cc b/test/cpp/qps/qps_test_openloop.cc index 52873b2987e..96a9b4504c9 100644 --- a/test/cpp/qps/qps_test_openloop.cc +++ b/test/cpp/qps/qps_test_openloop.cc @@ -60,7 +60,7 @@ static void RunQPS() { client_config.set_rpc_type(UNARY); client_config.set_load_type(POISSON); client_config.mutable_load_params()-> - mutable_poisson()->set_offered_load(10000.0); + mutable_poisson()->set_offered_load(1000.0); ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); From 13735d5d7e8b9413ec6ba54af4eeb0e88cd0302f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 1 Jul 2015 14:00:08 -0700 Subject: [PATCH 095/124] if->while --- test/cpp/qps/client_async.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 7c89a35ee7e..e1e44f9ac0d 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -201,7 +201,7 @@ class AsyncClient : public Client { } // Now clear out all the pre-allocated idle contexts for (int ch = 0; ch < channel_count_; ch++) { - if (!contexts_[ch].empty()) { + while (!contexts_[ch].empty()) { // Get an idle context from the front of the list auto* ctx = *(contexts_[ch].begin()); contexts_[ch].pop_front(); From 4bc49051ba823cfc9ddb342e08b1ab7638fa6396 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 1 Jul 2015 14:18:04 -0700 Subject: [PATCH 096/124] Skylark macro to generate an objc_library from protos Still needed: - Use compiled protoc. - Work with multiple proto sources. - Work with proto sources in nested dirs. --- grpc.bzl | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 grpc.bzl diff --git a/grpc.bzl b/grpc.bzl new file mode 100644 index 00000000000..9865bc734d3 --- /dev/null +++ b/grpc.bzl @@ -0,0 +1,68 @@ + +def _lower_underscore_to_upper_camel(str): + humps = [] + for hump in str.split('_'): + humps += [hump[0].upper() + hump[1:]] + return "".join(humps) + +def objc_grpc_library(name, srcs, visibility=None): + basename = srcs[0].split('/')[-1] + filename = basename[:-6] # remove .proto suffix + filename = _lower_underscore_to_upper_camel(filename) + + protoc_command = "protoc -I . " + srcs_params = "" + for src in srcs: + srcs_params += " $(location %s)" % (src) + + # Messages + protoc_messages_flags = "--objc_out=$(GENDIR)" + native.genrule( + name = name + "_mesages_codegen", + srcs = srcs, + outs = [ + filename + ".pbobjc.h", + filename + ".pbobjc.m", + ], + cmd = protoc_command + protoc_messages_flags + srcs_params, + ) + native.objc_library( + name = name + "_messages", + hdrs = [ + ":" + filename + ".pbobjc.h", + ], + includes = ["."], + non_arc_srcs = [ + ":" + filename + ".pbobjc.m", + ], + deps = [ + "//external:protobuf_objc", + ], + ) + + # Services + protoc_services_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" + native.genrule( + name = name + "_codegen", + srcs = srcs + ["//external:grpc_protoc_plugin_objc"], + outs = [ + filename + ".pbrpc.h", + filename + ".pbrpc.m", + ], + cmd = protoc_command + protoc_services_flags + srcs_params, + ) + native.objc_library( + name = name, + hdrs = [ + ":" + filename + ".pbrpc.h", + ], + includes = ["."], + srcs = [ + ":" + filename + ".pbrpc.m", + ], + deps = [ + ":" + name + "_messages", + "//external:proto_objc_rpc", + ], + visibility = visibility, + ) From 9d94b60c0ab3a945576ef0cf7385be8eea6c99e2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 14:23:18 -0700 Subject: [PATCH 097/124] Expand comment --- src/core/channel/client_channel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 1eab87d7149..e05bda7f2d1 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -60,7 +60,8 @@ typedef struct { /** master channel */ grpc_channel *master; - /** mutex protecting client configuration, resolution state */ + /** mutex protecting client configuration, including all + variables below in this data structure */ gpr_mu mu_config; /** currently active load balancer - guarded by mu_config */ grpc_lb_policy *lb_policy; From 50bc609f6e4395ff87ff6d7f5223f625e4360831 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 14:25:19 -0700 Subject: [PATCH 098/124] Expand comment --- src/core/channel/client_channel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index e05bda7f2d1..871e970eb8d 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -57,7 +57,10 @@ typedef struct { grpc_mdctx *mdctx; /** resolver for this channel */ grpc_resolver *resolver; - /** master channel */ + /** master channel - the grpc_channel instance that ultimately owns + this channel_data via its channel stack. + We occasionally use this to bump the refcount on the master channel + to keep ourselves alive through an asynchronous operation. */ grpc_channel *master; /** mutex protecting client configuration, including all From f037011b1f6d89705a631fd08524f0a0b5611c65 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 14:26:11 -0700 Subject: [PATCH 099/124] Expand comment --- src/core/client_config/subchannel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 93c703e7c44..6cf9062ab0c 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -79,7 +79,10 @@ struct grpc_subchannel { size_t addr_len; /** metadata context */ grpc_mdctx *mdctx; - /** master channel */ + /** master channel - the grpc_channel instance that ultimately owns + this channel_data via its channel stack. + We occasionally use this to bump the refcount on the master channel + to keep ourselves alive through an asynchronous operation. */ grpc_channel *master; /** have we seen a disconnection? */ int disconnected; From 7d138014bdeabf88bf45d8a0966021937e82a414 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 15:20:30 -0700 Subject: [PATCH 100/124] Correct comments --- src/core/client_config/resolvers/dns_resolver.h | 2 +- src/core/client_config/resolvers/unix_resolver_posix.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/client_config/resolvers/dns_resolver.h b/src/core/client_config/resolvers/dns_resolver.h index 09322b16cf3..a3ef3161a63 100644 --- a/src/core/client_config/resolvers/dns_resolver.h +++ b/src/core/client_config/resolvers/dns_resolver.h @@ -36,7 +36,7 @@ #include "src/core/client_config/resolver_factory.h" -/** Create a dns resolver for \a name */ +/** Create a dns resolver factory */ grpc_resolver_factory *grpc_dns_resolver_factory_create(void); #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H */ diff --git a/src/core/client_config/resolvers/unix_resolver_posix.h b/src/core/client_config/resolvers/unix_resolver_posix.h index a84906f4d65..57ace59e218 100644 --- a/src/core/client_config/resolvers/unix_resolver_posix.h +++ b/src/core/client_config/resolvers/unix_resolver_posix.h @@ -38,7 +38,7 @@ #include "src/core/client_config/resolver_factory.h" -/** Create a dns resolver for \a name */ +/** Create a unix resolver factory */ grpc_resolver_factory *grpc_unix_resolver_factory_create(void); #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_UNIX_RESOLVER_H */ From fc5fb879a6a05826f9b9078d172e2d59a1e8be43 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 1 Jul 2015 15:29:30 -0700 Subject: [PATCH 101/124] Support sources in nested dirs --- grpc.bzl | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/grpc.bzl b/grpc.bzl index 9865bc734d3..2ad3b03b576 100644 --- a/grpc.bzl +++ b/grpc.bzl @@ -6,7 +6,9 @@ def _lower_underscore_to_upper_camel(str): return "".join(humps) def objc_grpc_library(name, srcs, visibility=None): - basename = srcs[0].split('/')[-1] + src_path_elements = srcs[0].split('/') + src_dir = '/'.join(src_path_elements[:-1]) + basename = src_path_elements[-1] filename = basename[:-6] # remove .proto suffix filename = _lower_underscore_to_upper_camel(filename) @@ -17,24 +19,19 @@ def objc_grpc_library(name, srcs, visibility=None): # Messages protoc_messages_flags = "--objc_out=$(GENDIR)" + message_header = src_dir + '/' + filename + ".pbobjc.h" + message_implementation = src_dir + '/' + filename + ".pbobjc.m" native.genrule( name = name + "_mesages_codegen", srcs = srcs, - outs = [ - filename + ".pbobjc.h", - filename + ".pbobjc.m", - ], + outs = [message_header, message_implementation], cmd = protoc_command + protoc_messages_flags + srcs_params, ) native.objc_library( name = name + "_messages", - hdrs = [ - ":" + filename + ".pbobjc.h", - ], + hdrs = [message_header], includes = ["."], - non_arc_srcs = [ - ":" + filename + ".pbobjc.m", - ], + non_arc_srcs = [message_implementation], deps = [ "//external:protobuf_objc", ], @@ -42,24 +39,19 @@ def objc_grpc_library(name, srcs, visibility=None): # Services protoc_services_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" + service_header = src_dir + '/' + filename + ".pbrpc.h" + service_implementation = src_dir + '/' + filename + ".pbrpc.m" native.genrule( name = name + "_codegen", srcs = srcs + ["//external:grpc_protoc_plugin_objc"], - outs = [ - filename + ".pbrpc.h", - filename + ".pbrpc.m", - ], + outs = [service_header, service_implementation], cmd = protoc_command + protoc_services_flags + srcs_params, ) native.objc_library( name = name, - hdrs = [ - ":" + filename + ".pbrpc.h", - ], + hdrs = [service_header], includes = ["."], - srcs = [ - ":" + filename + ".pbrpc.m", - ], + srcs = [service_implementation], deps = [ ":" + name + "_messages", "//external:proto_objc_rpc", From 51fbeb0c7c1f9d6f92fd66adcb1c788bdfce29e2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 15:43:28 -0700 Subject: [PATCH 102/124] Remove debug code --- src/core/transport/connectivity_state.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/transport/connectivity_state.c b/src/core/transport/connectivity_state.c index dabe46badd7..1091ceae441 100644 --- a/src/core/transport/connectivity_state.c +++ b/src/core/transport/connectivity_state.c @@ -39,12 +39,10 @@ void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state init_state) { tracker->current_state = init_state; tracker->watchers = NULL; - /*gpr_log(GPR_DEBUG, "CS:%p:init:%d", tracker, init_state);*/ } void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker) { grpc_connectivity_state_watcher *w; - /*gpr_log(GPR_DEBUG, "CS:%p:destroy", tracker);*/ while ((w = tracker->watchers)) { tracker->watchers = w->next; @@ -84,7 +82,6 @@ void grpc_connectivity_state_set_with_scheduler( void (*scheduler)(void *arg, grpc_iomgr_closure *closure), void *arg) { grpc_connectivity_state_watcher *new = NULL; grpc_connectivity_state_watcher *w; - /*gpr_log(GPR_DEBUG, "CS:%p:set:%d", tracker, state);*/ if (tracker->current_state == state) { return; } From 164f633283259a3f1306e3546910c9fcaaa56bbb Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 1 Jul 2015 18:29:21 -0700 Subject: [PATCH 103/124] Extract filename transformations into functions --- grpc.bzl | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/grpc.bzl b/grpc.bzl index 2ad3b03b576..f31e188dd60 100644 --- a/grpc.bzl +++ b/grpc.bzl @@ -5,22 +5,28 @@ def _lower_underscore_to_upper_camel(str): humps += [hump[0].upper() + hump[1:]] return "".join(humps) -def objc_grpc_library(name, srcs, visibility=None): - src_path_elements = srcs[0].split('/') - src_dir = '/'.join(src_path_elements[:-1]) - basename = src_path_elements[-1] - filename = basename[:-6] # remove .proto suffix - filename = _lower_underscore_to_upper_camel(filename) +def _file_to_upper_camel(src): + elements = src.rpartition('/') + upper_camel = _lower_underscore_to_upper_camel(elements[-1]) + return "".join(elements[:-1] + [upper_camel]) + +def _file_with_extension(src, ext): + elements = src.rpartition('/') + basename = elements[-1].partition('.')[0] + return "".join(elements[:-1] + [basename, ext]) +def objc_grpc_library(name, srcs, visibility=None): protoc_command = "protoc -I . " srcs_params = "" for src in srcs: srcs_params += " $(location %s)" % (src) + src = _file_to_upper_camel(srcs[0]) + # Messages protoc_messages_flags = "--objc_out=$(GENDIR)" - message_header = src_dir + '/' + filename + ".pbobjc.h" - message_implementation = src_dir + '/' + filename + ".pbobjc.m" + message_header = _file_with_extension(src, ".pbobjc.h") + message_implementation = _file_with_extension(src, ".pbobjc.m") native.genrule( name = name + "_mesages_codegen", srcs = srcs, @@ -39,8 +45,8 @@ def objc_grpc_library(name, srcs, visibility=None): # Services protoc_services_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" - service_header = src_dir + '/' + filename + ".pbrpc.h" - service_implementation = src_dir + '/' + filename + ".pbrpc.m" + service_header = _file_with_extension(src, ".pbrpc.h") + service_implementation = _file_with_extension(src, ".pbrpc.m") native.genrule( name = name + "_codegen", srcs = srcs + ["//external:grpc_protoc_plugin_objc"], From d9435277fbb686da64ac831bc085f2670d5c2977 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 1 Jul 2015 18:43:54 -0700 Subject: [PATCH 104/124] Split messages and services macros --- grpc.bzl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/grpc.bzl b/grpc.bzl index f31e188dd60..2e4528cb2c1 100644 --- a/grpc.bzl +++ b/grpc.bzl @@ -15,43 +15,49 @@ def _file_with_extension(src, ext): basename = elements[-1].partition('.')[0] return "".join(elements[:-1] + [basename, ext]) -def objc_grpc_library(name, srcs, visibility=None): +def _protoc_invocation(srcs, flags): protoc_command = "protoc -I . " srcs_params = "" for src in srcs: srcs_params += " $(location %s)" % (src) + return protoc_command + flags + srcs_params +def objc_proto_library(name, srcs, visibility=None): src = _file_to_upper_camel(srcs[0]) - # Messages - protoc_messages_flags = "--objc_out=$(GENDIR)" + protoc_flags = "--objc_out=$(GENDIR)" message_header = _file_with_extension(src, ".pbobjc.h") message_implementation = _file_with_extension(src, ".pbobjc.m") native.genrule( - name = name + "_mesages_codegen", + name = name + "_codegen", srcs = srcs, outs = [message_header, message_implementation], - cmd = protoc_command + protoc_messages_flags + srcs_params, + cmd = _protoc_invocation(srcs, protoc_flags), ) native.objc_library( - name = name + "_messages", + name = name, hdrs = [message_header], includes = ["."], non_arc_srcs = [message_implementation], deps = [ "//external:protobuf_objc", ], + visibility = visibility, ) - # Services - protoc_services_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" +def objc_grpc_library(name, srcs, visibility=None): + objc_proto_library(name + "_messages", srcs, visibility) + + src = _file_to_upper_camel(srcs[0]) + + protoc_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" service_header = _file_with_extension(src, ".pbrpc.h") service_implementation = _file_with_extension(src, ".pbrpc.m") native.genrule( name = name + "_codegen", srcs = srcs + ["//external:grpc_protoc_plugin_objc"], outs = [service_header, service_implementation], - cmd = protoc_command + protoc_services_flags + srcs_params, + cmd = _protoc_invocation(srcs, protoc_flags), ) native.objc_library( name = name, From 907fad9c4d03e081b670492a5b872628a0c7a8ac Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 2 Jul 2015 00:51:01 -0700 Subject: [PATCH 105/124] Support multiple proto sources --- grpc.bzl | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/grpc.bzl b/grpc.bzl index 2e4528cb2c1..0e94c4faf81 100644 --- a/grpc.bzl +++ b/grpc.bzl @@ -23,47 +23,53 @@ def _protoc_invocation(srcs, flags): return protoc_command + flags + srcs_params def objc_proto_library(name, srcs, visibility=None): - src = _file_to_upper_camel(srcs[0]) + h_files = [] + m_files = [] + for src in srcs: + src = _file_to_upper_camel(src) + h_files += [_file_with_extension(src, ".pbobjc.h")] + m_files += [_file_with_extension(src, ".pbobjc.m")] protoc_flags = "--objc_out=$(GENDIR)" - message_header = _file_with_extension(src, ".pbobjc.h") - message_implementation = _file_with_extension(src, ".pbobjc.m") + native.genrule( name = name + "_codegen", srcs = srcs, - outs = [message_header, message_implementation], + outs = h_files + m_files, cmd = _protoc_invocation(srcs, protoc_flags), ) native.objc_library( name = name, - hdrs = [message_header], + hdrs = h_files, includes = ["."], - non_arc_srcs = [message_implementation], - deps = [ - "//external:protobuf_objc", - ], + non_arc_srcs = m_files, + deps = ["//external:protobuf_objc"], visibility = visibility, ) -def objc_grpc_library(name, srcs, visibility=None): - objc_proto_library(name + "_messages", srcs, visibility) +def objc_grpc_library(name, services, other_messages, visibility=None): + objc_proto_library(name + "_messages", services + other_messages) - src = _file_to_upper_camel(srcs[0]) + h_files = [] + m_files = [] + for src in services: + src = _file_to_upper_camel(src) + h_files += [_file_with_extension(src, ".pbrpc.h")] + m_files += [_file_with_extension(src, ".pbrpc.m")] protoc_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" - service_header = _file_with_extension(src, ".pbrpc.h") - service_implementation = _file_with_extension(src, ".pbrpc.m") + native.genrule( name = name + "_codegen", - srcs = srcs + ["//external:grpc_protoc_plugin_objc"], - outs = [service_header, service_implementation], - cmd = _protoc_invocation(srcs, protoc_flags), + srcs = services + ["//external:grpc_protoc_plugin_objc"], + outs = h_files + m_files, + cmd = _protoc_invocation(services, protoc_flags), ) native.objc_library( name = name, - hdrs = [service_header], + hdrs = h_files, includes = ["."], - srcs = [service_implementation], + srcs = m_files, deps = [ ":" + name + "_messages", "//external:proto_objc_rpc", From 8637ececfd15c7325cf99a965a54387c7d994ad8 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 2 Jul 2015 01:01:53 -0700 Subject: [PATCH 106/124] Use a protoc compiled from sources --- grpc.bzl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/grpc.bzl b/grpc.bzl index 0e94c4faf81..5b5735e1bc4 100644 --- a/grpc.bzl +++ b/grpc.bzl @@ -16,7 +16,7 @@ def _file_with_extension(src, ext): return "".join(elements[:-1] + [basename, ext]) def _protoc_invocation(srcs, flags): - protoc_command = "protoc -I . " + protoc_command = "$(location //external:protoc) -I . " srcs_params = "" for src in srcs: srcs_params += " $(location %s)" % (src) @@ -34,7 +34,7 @@ def objc_proto_library(name, srcs, visibility=None): native.genrule( name = name + "_codegen", - srcs = srcs, + srcs = srcs + ["//external:protoc"], outs = h_files + m_files, cmd = _protoc_invocation(srcs, protoc_flags), ) @@ -61,7 +61,10 @@ def objc_grpc_library(name, services, other_messages, visibility=None): native.genrule( name = name + "_codegen", - srcs = services + ["//external:grpc_protoc_plugin_objc"], + srcs = services + [ + "//external:grpc_protoc_plugin_objc", + "//external:protoc", + ], outs = h_files + m_files, cmd = _protoc_invocation(services, protoc_flags), ) From 24b2f67b80320d1f215c6465ea0092b7b01caa04 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 2 Jul 2015 01:29:37 -0700 Subject: [PATCH 107/124] Add copyright notice and documentation to .bzl file. --- grpc.bzl | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/grpc.bzl b/grpc.bzl index 5b5735e1bc4..9f2693126af 100644 --- a/grpc.bzl +++ b/grpc.bzl @@ -1,3 +1,39 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Bazel macros to declare gRPC libraries automatically generated from proto files. + +This file declares two macros: +- objc_proto_library +- objc_grpc_library +""" def _lower_underscore_to_upper_camel(str): humps = [] @@ -16,6 +52,9 @@ def _file_with_extension(src, ext): return "".join(elements[:-1] + [basename, ext]) def _protoc_invocation(srcs, flags): + """Returns a command line to invoke protoc from a genrule, on the given + sources, using the given flags. + """ protoc_command = "$(location //external:protoc) -I . " srcs_params = "" for src in srcs: @@ -23,6 +62,9 @@ def _protoc_invocation(srcs, flags): return protoc_command + flags + srcs_params def objc_proto_library(name, srcs, visibility=None): + """Declares an objc_library for the code generated by protoc from the given + proto sources. This generated code doesn't include proto services. + """ h_files = [] m_files = [] for src in srcs: @@ -48,6 +90,10 @@ def objc_proto_library(name, srcs, visibility=None): ) def objc_grpc_library(name, services, other_messages, visibility=None): + """Declares an objc_library for the code generated by gRPC and protoc from the + given proto sources (services and other_messages). The generated code doesn't + include proto services of the files passed as other_messages. + """ objc_proto_library(name + "_messages", services + other_messages) h_files = [] @@ -57,7 +103,8 @@ def objc_grpc_library(name, services, other_messages, visibility=None): h_files += [_file_with_extension(src, ".pbrpc.h")] m_files += [_file_with_extension(src, ".pbrpc.m")] - protoc_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" + protoc_flags = ("--grpc_out=$(GENDIR) --plugin=" + + "protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)") native.genrule( name = name + "_codegen", From 3beb240544bd7a7dc192c2c2fb343e924d5bece0 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 2 Jul 2015 01:30:33 -0700 Subject: [PATCH 108/124] Minor doc fix in BUILD and BUILD.template --- BUILD | 2 +- templates/BUILD.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 8a827ff54e1..b98c0883d5c 100644 --- a/BUILD +++ b/BUILD @@ -1,5 +1,5 @@ # GRPC Bazel BUILD file. -# This currently builds C and C++ code. +# This currently builds C, C++ and Objective-C code. # This file has been automatically generated from a template file. # Please look at the templates directory instead. # This file can be regenerated from the template by running diff --git a/templates/BUILD.template b/templates/BUILD.template index dffdc1dddde..4e9d8c376a9 100644 --- a/templates/BUILD.template +++ b/templates/BUILD.template @@ -1,5 +1,5 @@ # GRPC Bazel BUILD file. -# This currently builds C and C++ code. +# This currently builds C, C++ and Objective-C code. # This file has been automatically generated from a template file. # Please look at the templates directory instead. # This file can be regenerated from the template by running From cae5bf586f122871111229ace6a86dcdb8214e45 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 2 Jul 2015 08:46:59 -0700 Subject: [PATCH 109/124] Structure repacking and sizing --- src/core/iomgr/alarm.h | 2 +- src/core/surface/call.c | 8 ++++---- src/core/surface/call.h | 2 +- src/core/transport/stream_op.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/iomgr/alarm.h b/src/core/iomgr/alarm.h index e5262e21998..c067a0b8a3e 100644 --- a/src/core/iomgr/alarm.h +++ b/src/core/iomgr/alarm.h @@ -41,9 +41,9 @@ typedef struct grpc_alarm { gpr_timespec deadline; gpr_uint32 heap_index; /* INVALID_HEAP_INDEX if not in heap */ + int triggered; struct grpc_alarm *next; struct grpc_alarm *prev; - int triggered; grpc_iomgr_cb_func cb; void *cb_arg; } grpc_alarm; diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 181617fff80..f6aeed856ba 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -76,14 +76,14 @@ typedef struct { typedef struct { /* Overall status of the operation: starts OK, may degrade to non-OK */ - int success; - /* Completion function to call at the end of the operation */ - grpc_ioreq_completion_func on_complete; - void *user_data; + gpr_uint8 success; /* a bit mask of which request ops are needed (1u << opid) */ gpr_uint16 need_mask; /* a bit mask of which request ops are now completed */ gpr_uint16 complete_mask; + /* Completion function to call at the end of the operation */ + grpc_ioreq_completion_func on_complete; + void *user_data; } reqinfo_master; /* Status data for a request can come from several sources; this diff --git a/src/core/surface/call.h b/src/core/surface/call.h index fb3662b50d3..3b6f9c942eb 100644 --- a/src/core/surface/call.h +++ b/src/core/surface/call.h @@ -78,8 +78,8 @@ typedef union { typedef struct { grpc_ioreq_op op; - grpc_ioreq_data data; gpr_uint32 flags; /**< A copy of the write flags from grpc_op */ + grpc_ioreq_data data; } grpc_ioreq; typedef void (*grpc_ioreq_completion_func)(grpc_call *call, int success, diff --git a/src/core/transport/stream_op.h b/src/core/transport/stream_op.h index 842fc932b96..964d39d14fc 100644 --- a/src/core/transport/stream_op.h +++ b/src/core/transport/stream_op.h @@ -41,7 +41,7 @@ #include "src/core/transport/metadata.h" /* this many stream ops are inlined into a sopb before allocating */ -#define GRPC_SOPB_INLINE_ELEMENTS 16 +#define GRPC_SOPB_INLINE_ELEMENTS 4 /* Operations that can be performed on a stream. Used by grpc_stream_op. */ From 9506819c5013f6a2e8561fc66ebcf86dec174f96 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 2 Jul 2015 20:18:43 -0700 Subject: [PATCH 110/124] Fix build breakage of moving include/grpc/ into grpc/ --- gRPC.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gRPC.podspec b/gRPC.podspec index 1a4dfd4c9a6..138cf96fd04 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -494,9 +494,9 @@ Pod::Spec.new do |s| BAD_TIME="$DIR_TIME/time.h" GOOD_TIME="$DIR_TIME/grpc_time.h" grep -rl "$BAD_TIME" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g - if [ -f "include/$BAD_TIME" ]; + if [ -f "$BAD_TIME" ]; then - mv -f "include/$BAD_TIME" "include/$GOOD_TIME" + mv -f "$BAD_TIME" "$GOOD_TIME" fi DIR_STRING="src/core/support" From 951cd18309958d7ad2992d43ac565e91089b5d8c Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 2 Jul 2015 20:48:50 -0700 Subject: [PATCH 111/124] Fix build breakage of moving include/grpc/ into grpc/ --- templates/gRPC.podspec.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index deea07cee35..495ea49c9c2 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -111,9 +111,9 @@ Pod::Spec.new do |s| BAD_TIME="$DIR_TIME/time.h" GOOD_TIME="$DIR_TIME/grpc_time.h" grep -rl "$BAD_TIME" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g - if [ -f "include/$BAD_TIME" ]; + if [ -f "$BAD_TIME" ]; then - mv -f "include/$BAD_TIME" "include/$GOOD_TIME" + mv -f "$BAD_TIME" "$GOOD_TIME" fi DIR_STRING="src/core/support" From 469d4b6fde8084232cafa3972691d20b6cb359c7 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Fri, 3 Jul 2015 12:02:38 -0700 Subject: [PATCH 112/124] Rename GRPCMethodName->ProtoMethod --- src/objective-c/GRPCClient/GRPCCall.h | 4 ++-- src/objective-c/GRPCClient/GRPCCall.m | 4 ++-- .../GRPCClient/{GRPCMethodName.h => ProtoMethod.h} | 2 +- .../GRPCClient/{GRPCMethodName.m => ProtoMethod.m} | 4 ++-- .../private/GRPCMethodName+HTTP2Encoding.h | 4 ++-- .../private/GRPCMethodName+HTTP2Encoding.m | 2 +- src/objective-c/ProtoRPC/ProtoRPC.h | 2 +- src/objective-c/ProtoRPC/ProtoRPC.m | 4 ++-- src/objective-c/ProtoRPC/ProtoService.m | 4 ++-- src/objective-c/tests/GRPCClientTests.m | 14 +++++++------- src/objective-c/tests/LocalClearTextTests.m | 6 +++--- 11 files changed, 25 insertions(+), 25 deletions(-) rename src/objective-c/GRPCClient/{GRPCMethodName.h => ProtoMethod.h} (98%) rename src/objective-c/GRPCClient/{GRPCMethodName.m => ProtoMethod.m} (97%) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 33aae107475..ed59817952c 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -48,7 +48,7 @@ #import #import -@class GRPCMethodName; +@class ProtoMethod; // Key used in |NSError|'s |userInfo| dictionary to store the response metadata sent by the server. extern id const kGRPCStatusMetadataKey; @@ -90,7 +90,7 @@ extern id const kGRPCStatusMetadataKey; // the specific remote method called). // To finish a call right away, invoke cancel. - (instancetype)initWithHost:(NSString *)host - method:(GRPCMethodName *)method + method:(ProtoMethod *)method requestsWriter:(id)requestsWriter NS_DESIGNATED_INITIALIZER; // Finishes the request side of this call, notifies the server that the RPC diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 77eebeff761..08b28282941 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -36,7 +36,7 @@ #include #include -#import "GRPCMethodName.h" +#import "ProtoMethod.h" #import "private/GRPCChannel.h" #import "private/GRPCCompletionQueue.h" #import "private/GRPCDelegateWrapper.h" @@ -95,7 +95,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey"; // Designated initializer - (instancetype)initWithHost:(NSString *)host - method:(GRPCMethodName *)method + method:(ProtoMethod *)method requestsWriter:(id)requestWriter { if (!host || !method) { [NSException raise:NSInvalidArgumentException format:@"Neither host nor method can be nil."]; diff --git a/src/objective-c/GRPCClient/GRPCMethodName.h b/src/objective-c/GRPCClient/ProtoMethod.h similarity index 98% rename from src/objective-c/GRPCClient/GRPCMethodName.h rename to src/objective-c/GRPCClient/ProtoMethod.h index fe153dd478b..814c1564641 100644 --- a/src/objective-c/GRPCClient/GRPCMethodName.h +++ b/src/objective-c/GRPCClient/ProtoMethod.h @@ -39,7 +39,7 @@ // implement multiple interfaces. // TODO(jcanizales): Move to ProtoRPC package. // TODO(jcanizales): Rename interface -> service. -@interface GRPCMethodName : NSObject +@interface ProtoMethod : NSObject @property(nonatomic, readonly) NSString *package; @property(nonatomic, readonly) NSString *interface; @property(nonatomic, readonly) NSString *method; diff --git a/src/objective-c/GRPCClient/GRPCMethodName.m b/src/objective-c/GRPCClient/ProtoMethod.m similarity index 97% rename from src/objective-c/GRPCClient/GRPCMethodName.m rename to src/objective-c/GRPCClient/ProtoMethod.m index 96724073a5f..1f5f836b7d0 100644 --- a/src/objective-c/GRPCClient/GRPCMethodName.m +++ b/src/objective-c/GRPCClient/ProtoMethod.m @@ -31,9 +31,9 @@ * */ -#import "GRPCMethodName.h" +#import "ProtoMethod.h" -@implementation GRPCMethodName +@implementation ProtoMethod - (instancetype)initWithPackage:(NSString *)package interface:(NSString *)interface method:(NSString *)method { diff --git a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h index 81c80f2a492..ac1872879cd 100644 --- a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h +++ b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h @@ -33,8 +33,8 @@ #import -#import "GRPCClient/GRPCMethodName.h" +#import "GRPCClient/ProtoMethod.h" -@interface GRPCMethodName (HTTP2Encoding) +@interface ProtoMethod (HTTP2Encoding) - (NSString *)HTTP2Path; @end diff --git a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m index 3ad757fb29a..f31d33408b0 100644 --- a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m +++ b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m @@ -33,7 +33,7 @@ #import "GRPCMethodName+HTTP2Encoding.h" -@implementation GRPCMethodName (HTTP2Encoding) +@implementation ProtoMethod (HTTP2Encoding) - (NSString *)HTTP2Path { if (self.package) { return [NSString stringWithFormat:@"/%@.%@/%@", self.package, self.interface, self.method]; diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index a3833106195..c5ab345c9cf 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -37,7 +37,7 @@ @interface ProtoRPC : GRPCCall - (instancetype)initWithHost:(NSString *)host - method:(GRPCMethodName *)method + method:(ProtoMethod *)method requestsWriter:(id)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable NS_DESIGNATED_INITIALIZER; diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 4da646d7b45..ec38077b714 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -43,7 +43,7 @@ } - (instancetype)initWithHost:(NSString *)host - method:(GRPCMethodName *)method + method:(ProtoMethod *)method requestsWriter:(id)requestsWriter { return [self initWithHost:host method:method @@ -54,7 +54,7 @@ // Designated initializer - (instancetype)initWithHost:(NSString *)host - method:(GRPCMethodName *)method + method:(ProtoMethod *)method requestsWriter:(id)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable { diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index 47bdb5dc6e8..e8939389332 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -33,7 +33,7 @@ #import "ProtoService.h" -#import +#import #import #import @@ -69,7 +69,7 @@ requestsWriter:(id)requestsWriter responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable { - GRPCMethodName *methodName = [[GRPCMethodName alloc] initWithPackage:_packageName + ProtoMethod *methodName = [[ProtoMethod alloc] initWithPackage:_packageName interface:_serviceName method:method]; return [[ProtoRPC alloc] initWithHost:_host diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index e421127ea1e..e3b37b050e4 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -35,7 +35,7 @@ #import #import -#import +#import #import #import #import @@ -47,9 +47,9 @@ static NSString * const kHostAddress = @"grpc-test.sandbox.google.com"; static NSString * const kPackage = @"grpc.testing"; static NSString * const kService = @"TestService"; -static GRPCMethodName *kInexistentMethod; -static GRPCMethodName *kEmptyCallMethod; -static GRPCMethodName *kUnaryCallMethod; +static ProtoMethod *kInexistentMethod; +static ProtoMethod *kEmptyCallMethod; +static ProtoMethod *kUnaryCallMethod; @interface GRPCClientTests : XCTestCase @end @@ -58,13 +58,13 @@ static GRPCMethodName *kUnaryCallMethod; - (void)setUp { // This method isn't implemented by the remote server. - kInexistentMethod = [[GRPCMethodName alloc] initWithPackage:kPackage + kInexistentMethod = [[ProtoMethod alloc] initWithPackage:kPackage interface:kService method:@"Inexistent"]; - kEmptyCallMethod = [[GRPCMethodName alloc] initWithPackage:kPackage + kEmptyCallMethod = [[ProtoMethod alloc] initWithPackage:kPackage interface:kService method:@"EmptyCall"]; - kUnaryCallMethod = [[GRPCMethodName alloc] initWithPackage:kPackage + kUnaryCallMethod = [[ProtoMethod alloc] initWithPackage:kPackage interface:kService method:@"UnaryCall"]; } diff --git a/src/objective-c/tests/LocalClearTextTests.m b/src/objective-c/tests/LocalClearTextTests.m index 05cc10410a1..ace100847fe 100644 --- a/src/objective-c/tests/LocalClearTextTests.m +++ b/src/objective-c/tests/LocalClearTextTests.m @@ -35,7 +35,7 @@ #import #import -#import +#import #import #import #import @@ -87,7 +87,7 @@ static NSString * const kService = @"RouteGuide"; __weak XCTestExpectation *response = [self expectationWithDescription:@"Empty response received."]; __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."]; - GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage + ProtoMethod *method = [[ProtoMethod alloc] initWithPackage:kPackage interface:kService method:@"RecordRoute"]; @@ -115,7 +115,7 @@ static NSString * const kService = @"RouteGuide"; __weak XCTestExpectation *response = [self expectationWithDescription:@"Response received."]; __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."]; - GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage + ProtoMethod *method = [[ProtoMethod alloc] initWithPackage:kPackage interface:kService method:@"GetFeature"]; From 1ac8f9a26aab6fc6cfff967073e81ec3c84a07c2 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Fri, 3 Jul 2015 12:05:04 -0700 Subject: [PATCH 113/124] Rename interface->service --- src/objective-c/GRPCClient/ProtoMethod.h | 3 +-- src/objective-c/GRPCClient/ProtoMethod.m | 2 +- .../GRPCClient/private/GRPCMethodName+HTTP2Encoding.m | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/objective-c/GRPCClient/ProtoMethod.h b/src/objective-c/GRPCClient/ProtoMethod.h index 814c1564641..86d582a03e5 100644 --- a/src/objective-c/GRPCClient/ProtoMethod.h +++ b/src/objective-c/GRPCClient/ProtoMethod.h @@ -38,10 +38,9 @@ // A fully-qualified gRPC method name. Full qualification is needed because a gRPC endpoint can // implement multiple interfaces. // TODO(jcanizales): Move to ProtoRPC package. -// TODO(jcanizales): Rename interface -> service. @interface ProtoMethod : NSObject @property(nonatomic, readonly) NSString *package; -@property(nonatomic, readonly) NSString *interface; +@property(nonatomic, readonly) NSString *service; @property(nonatomic, readonly) NSString *method; - (instancetype)initWithPackage:(NSString *)package interface:(NSString *)interface diff --git a/src/objective-c/GRPCClient/ProtoMethod.m b/src/objective-c/GRPCClient/ProtoMethod.m index 1f5f836b7d0..4c78b4f61c7 100644 --- a/src/objective-c/GRPCClient/ProtoMethod.m +++ b/src/objective-c/GRPCClient/ProtoMethod.m @@ -39,7 +39,7 @@ method:(NSString *)method { if ((self = [super init])) { _package = [package copy]; - _interface = [interface copy]; + _service = [interface copy]; _method = [method copy]; } return self; diff --git a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m index f31d33408b0..cb4efc82cfd 100644 --- a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m +++ b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m @@ -36,9 +36,9 @@ @implementation ProtoMethod (HTTP2Encoding) - (NSString *)HTTP2Path { if (self.package) { - return [NSString stringWithFormat:@"/%@.%@/%@", self.package, self.interface, self.method]; + return [NSString stringWithFormat:@"/%@.%@/%@", self.package, self.service, self.method]; } else { - return [NSString stringWithFormat:@"/%@/%@", self.interface, self.method]; + return [NSString stringWithFormat:@"/%@/%@", self.service, self.method]; } } @end From be808e36f6dc9fd73b031520baf3e94c81307230 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Sat, 4 Jul 2015 14:37:58 -0700 Subject: [PATCH 114/124] Move ProtoMethod to ProtoRPC package --- src/objective-c/GRPCClient/GRPCCall.h | 4 +- src/objective-c/GRPCClient/GRPCCall.m | 10 ++--- .../private/GRPCMethodName+HTTP2Encoding.h | 40 ----------------- .../private/GRPCMethodName+HTTP2Encoding.m | 44 ------------------- .../GRPCClient/private/GRPCWrappedCall.h | 2 +- .../GRPCClient/private/GRPCWrappedCall.m | 8 ++-- .../{GRPCClient => ProtoRPC}/ProtoMethod.h | 12 ++--- .../{GRPCClient => ProtoRPC}/ProtoMethod.m | 12 ++++- src/objective-c/ProtoRPC/ProtoRPC.h | 2 + src/objective-c/ProtoRPC/ProtoRPC.m | 15 ++++--- src/objective-c/ProtoRPC/ProtoService.m | 6 +-- src/objective-c/tests/GRPCClientTests.m | 22 +++++----- src/objective-c/tests/LocalClearTextTests.m | 14 +++--- 13 files changed, 57 insertions(+), 134 deletions(-) delete mode 100644 src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h delete mode 100644 src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m rename src/objective-c/{GRPCClient => ProtoRPC}/ProtoMethod.h (86%) rename src/objective-c/{GRPCClient => ProtoRPC}/ProtoMethod.m (86%) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index ed59817952c..cba53fa2f67 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -48,8 +48,6 @@ #import #import -@class ProtoMethod; - // Key used in |NSError|'s |userInfo| dictionary to store the response metadata sent by the server. extern id const kGRPCStatusMetadataKey; @@ -90,7 +88,7 @@ extern id const kGRPCStatusMetadataKey; // the specific remote method called). // To finish a call right away, invoke cancel. - (instancetype)initWithHost:(NSString *)host - method:(ProtoMethod *)method + path:(NSString *)path requestsWriter:(id)requestsWriter NS_DESIGNATED_INITIALIZER; // Finishes the request side of this call, notifies the server that the RPC diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 08b28282941..4ac4e4d37f5 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -36,11 +36,9 @@ #include #include -#import "ProtoMethod.h" #import "private/GRPCChannel.h" #import "private/GRPCCompletionQueue.h" #import "private/GRPCDelegateWrapper.h" -#import "private/GRPCMethodName+HTTP2Encoding.h" #import "private/GRPCWrappedCall.h" #import "private/NSData+GRPC.h" #import "private/NSDictionary+GRPC.h" @@ -90,14 +88,14 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey"; @synthesize state = _state; - (instancetype)init { - return [self initWithHost:nil method:nil requestsWriter:nil]; + return [self initWithHost:nil path:nil requestsWriter:nil]; } // Designated initializer - (instancetype)initWithHost:(NSString *)host - method:(ProtoMethod *)method + path:(NSString *)path requestsWriter:(id)requestWriter { - if (!host || !method) { + if (!host || !path) { [NSException raise:NSInvalidArgumentException format:@"Neither host nor method can be nil."]; } if (requestWriter.state != GRXWriterStateNotStarted) { @@ -114,7 +112,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey"; _channel = [GRPCChannel channelToHost:host]; _wrappedCall = [[GRPCWrappedCall alloc] initWithChannel:_channel - method:method.HTTP2Path + path:path host:host]; // Serial queue to invoke the non-reentrant methods of the grpc_call object. diff --git a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h deleted file mode 100644 index ac1872879cd..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import - -#import "GRPCClient/ProtoMethod.h" - -@interface ProtoMethod (HTTP2Encoding) -- (NSString *)HTTP2Path; -@end diff --git a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m b/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m deleted file mode 100644 index cb4efc82cfd..00000000000 --- a/src/objective-c/GRPCClient/private/GRPCMethodName+HTTP2Encoding.m +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import "GRPCMethodName+HTTP2Encoding.h" - -@implementation ProtoMethod (HTTP2Encoding) -- (NSString *)HTTP2Path { - if (self.package) { - return [NSString stringWithFormat:@"/%@.%@/%@", self.package, self.service, self.method]; - } else { - return [NSString stringWithFormat:@"/%@/%@", self.service, self.method]; - } -} -@end diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h index c08aefc6a8f..18f8bb55310 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h @@ -84,7 +84,7 @@ @interface GRPCWrappedCall : NSObject - (instancetype)initWithChannel:(GRPCChannel *)channel - method:(NSString *)method + path:(NSString *)path host:(NSString *)host NS_DESIGNATED_INITIALIZER; - (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)())errorHandler; diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index d94b25091e6..45f10f5d63d 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -225,13 +225,13 @@ } - (instancetype)init { - return [self initWithChannel:nil method:nil host:nil]; + return [self initWithChannel:nil path:nil host:nil]; } - (instancetype)initWithChannel:(GRPCChannel *)channel - method:(NSString *)method + path:(NSString *)path host:(NSString *)host { - if (!channel || !method || !host) { + if (!channel || !path || !host) { [NSException raise:NSInvalidArgumentException format:@"channel, method, and host cannot be nil."]; } @@ -247,7 +247,7 @@ return nil; } _call = grpc_channel_create_call(channel.unmanagedChannel, _queue.unmanagedQueue, - method.UTF8String, host.UTF8String, gpr_inf_future); + path.UTF8String, host.UTF8String, gpr_inf_future); if (_call == NULL) { return nil; } diff --git a/src/objective-c/GRPCClient/ProtoMethod.h b/src/objective-c/ProtoRPC/ProtoMethod.h similarity index 86% rename from src/objective-c/GRPCClient/ProtoMethod.h rename to src/objective-c/ProtoRPC/ProtoMethod.h index 86d582a03e5..9ecb55a48fc 100644 --- a/src/objective-c/GRPCClient/ProtoMethod.h +++ b/src/objective-c/ProtoRPC/ProtoMethod.h @@ -33,16 +33,16 @@ #import -// See the README file for an introduction to this library. - -// A fully-qualified gRPC method name. Full qualification is needed because a gRPC endpoint can -// implement multiple interfaces. -// TODO(jcanizales): Move to ProtoRPC package. +// A fully-qualified proto service method name. Full qualification is needed because a gRPC endpoint +// can implement multiple services. @interface ProtoMethod : NSObject @property(nonatomic, readonly) NSString *package; @property(nonatomic, readonly) NSString *service; @property(nonatomic, readonly) NSString *method; + +@property(nonatomic, readonly) NSString *HTTP2Path; + - (instancetype)initWithPackage:(NSString *)package - interface:(NSString *)interface + service:(NSString *)service method:(NSString *)method; @end diff --git a/src/objective-c/GRPCClient/ProtoMethod.m b/src/objective-c/ProtoRPC/ProtoMethod.m similarity index 86% rename from src/objective-c/GRPCClient/ProtoMethod.m rename to src/objective-c/ProtoRPC/ProtoMethod.m index 4c78b4f61c7..245bf6180b0 100644 --- a/src/objective-c/GRPCClient/ProtoMethod.m +++ b/src/objective-c/ProtoRPC/ProtoMethod.m @@ -35,13 +35,21 @@ @implementation ProtoMethod - (instancetype)initWithPackage:(NSString *)package - interface:(NSString *)interface + service:(NSString *)service method:(NSString *)method { if ((self = [super init])) { _package = [package copy]; - _service = [interface copy]; + _service = [service copy]; _method = [method copy]; } return self; } + +- (NSString *)HTTP2Path { + if (_package) { + return [NSString stringWithFormat:@"/%@.%@/%@", _package, _service, _method]; + } else { + return [NSString stringWithFormat:@"/%@/%@", _service, _method]; + } +} @end diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index c5ab345c9cf..fcc0a507feb 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -34,6 +34,8 @@ #import #import +#import "ProtoMethod.h" + @interface ProtoRPC : GRPCCall - (instancetype)initWithHost:(NSString *)host diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index ec38077b714..3a99f1d5ded 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -42,15 +42,16 @@ id _responseWriteable; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" - (instancetype)initWithHost:(NSString *)host - method:(ProtoMethod *)method + path:(NSString *)path requestsWriter:(id)requestsWriter { - return [self initWithHost:host - method:method - requestsWriter:requestsWriter - responseClass:nil - responsesWriteable:nil]; + [NSException raise:NSInvalidArgumentException + format:@"Please use ProtoRPC's designated initializer instead."]; + return nil; } +#pragma clang diagnostic pop // Designated initializer - (instancetype)initWithHost:(NSString *)host @@ -70,7 +71,7 @@ // sending GPBMessages. return [proto data]; }]; - if ((self = [super initWithHost:host method:method requestsWriter:bytesWriter])) { + if ((self = [super initWithHost:host path:method.HTTP2Path requestsWriter:bytesWriter])) { // A writeable that parses the proto messages received. _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { [responsesWriteable writeValue:[responseClass parseFromData:value error:NULL]]; diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m index e8939389332..d7c5b6a8501 100644 --- a/src/objective-c/ProtoRPC/ProtoService.m +++ b/src/objective-c/ProtoRPC/ProtoService.m @@ -33,10 +33,10 @@ #import "ProtoService.h" -#import #import #import +#import "ProtoMethod.h" #import "ProtoRPC.h" @implementation ProtoService { @@ -70,8 +70,8 @@ responseClass:(Class)responseClass responsesWriteable:(id)responsesWriteable { ProtoMethod *methodName = [[ProtoMethod alloc] initWithPackage:_packageName - interface:_serviceName - method:method]; + service:_serviceName + method:method]; return [[ProtoRPC alloc] initWithHost:_host method:methodName requestsWriter:requestsWriter diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index e3b37b050e4..20a61b7b1cf 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -35,7 +35,7 @@ #import #import -#import +#import #import #import #import @@ -59,21 +59,21 @@ static ProtoMethod *kUnaryCallMethod; - (void)setUp { // This method isn't implemented by the remote server. kInexistentMethod = [[ProtoMethod alloc] initWithPackage:kPackage - interface:kService - method:@"Inexistent"]; + service:kService + method:@"Inexistent"]; kEmptyCallMethod = [[ProtoMethod alloc] initWithPackage:kPackage - interface:kService - method:@"EmptyCall"]; + service:kService + method:@"EmptyCall"]; kUnaryCallMethod = [[ProtoMethod alloc] initWithPackage:kPackage - interface:kService - method:@"UnaryCall"]; + service:kService + method:@"UnaryCall"]; } - (void)testConnectionToRemoteServer { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - method:kInexistentMethod + path:kInexistentMethod.HTTP2Path requestsWriter:[GRXWriter writerWithValue:[NSData data]]]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -95,7 +95,7 @@ static ProtoMethod *kUnaryCallMethod; __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - method:kEmptyCallMethod + path:kEmptyCallMethod.HTTP2Path requestsWriter:[GRXWriter writerWithValue:[NSData data]]]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -123,7 +123,7 @@ static ProtoMethod *kUnaryCallMethod; id requestsWriter = [GRXWriter writerWithValue:[request data]]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - method:kUnaryCallMethod + path:kUnaryCallMethod.HTTP2Path requestsWriter:requestsWriter]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -153,7 +153,7 @@ static ProtoMethod *kUnaryCallMethod; id requestsWriter = [GRXWriter writerWithValue:[request data]]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - method:kUnaryCallMethod + path:kUnaryCallMethod.HTTP2Path requestsWriter:requestsWriter]; call.requestMetadata[@"Authorization"] = @"Bearer bogusToken"; diff --git a/src/objective-c/tests/LocalClearTextTests.m b/src/objective-c/tests/LocalClearTextTests.m index ace100847fe..d9ad3455aff 100644 --- a/src/objective-c/tests/LocalClearTextTests.m +++ b/src/objective-c/tests/LocalClearTextTests.m @@ -35,7 +35,7 @@ #import #import -#import +#import #import #import #import @@ -88,13 +88,13 @@ static NSString * const kService = @"RouteGuide"; __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."]; ProtoMethod *method = [[ProtoMethod alloc] initWithPackage:kPackage - interface:kService - method:@"RecordRoute"]; + service:kService + method:@"RecordRoute"]; id requestsWriter = [GRXWriter emptyWriter]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost - method:method + path:method.HTTP2Path requestsWriter:requestsWriter]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -116,8 +116,8 @@ static NSString * const kService = @"RouteGuide"; __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."]; ProtoMethod *method = [[ProtoMethod alloc] initWithPackage:kPackage - interface:kService - method:@"GetFeature"]; + service:kService + method:@"GetFeature"]; RGDPoint *point = [RGDPoint message]; point.latitude = 28E7; @@ -125,7 +125,7 @@ static NSString * const kService = @"RouteGuide"; id requestsWriter = [GRXWriter writerWithValue:[point data]]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost - method:method + path:method.HTTP2Path requestsWriter:requestsWriter]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { From 5260f53cdad8202da3d70e42fa1886e17e8de66b Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Sat, 4 Jul 2015 14:47:41 -0700 Subject: [PATCH 115/124] Rename HTTP2Path -> HTTPPath --- src/objective-c/ProtoRPC/ProtoMethod.h | 2 +- src/objective-c/ProtoRPC/ProtoMethod.m | 2 +- src/objective-c/ProtoRPC/ProtoRPC.m | 2 +- src/objective-c/tests/GRPCClientTests.m | 8 ++++---- src/objective-c/tests/LocalClearTextTests.m | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/objective-c/ProtoRPC/ProtoMethod.h b/src/objective-c/ProtoRPC/ProtoMethod.h index 9ecb55a48fc..8f554a04832 100644 --- a/src/objective-c/ProtoRPC/ProtoMethod.h +++ b/src/objective-c/ProtoRPC/ProtoMethod.h @@ -40,7 +40,7 @@ @property(nonatomic, readonly) NSString *service; @property(nonatomic, readonly) NSString *method; -@property(nonatomic, readonly) NSString *HTTP2Path; +@property(nonatomic, readonly) NSString *HTTPPath; - (instancetype)initWithPackage:(NSString *)package service:(NSString *)service diff --git a/src/objective-c/ProtoRPC/ProtoMethod.m b/src/objective-c/ProtoRPC/ProtoMethod.m index 245bf6180b0..1113b4fbaa3 100644 --- a/src/objective-c/ProtoRPC/ProtoMethod.m +++ b/src/objective-c/ProtoRPC/ProtoMethod.m @@ -45,7 +45,7 @@ return self; } -- (NSString *)HTTP2Path { +- (NSString *)HTTPPath { if (_package) { return [NSString stringWithFormat:@"/%@.%@/%@", _package, _service, _method]; } else { diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 3a99f1d5ded..fe3ccf05413 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -71,7 +71,7 @@ // sending GPBMessages. return [proto data]; }]; - if ((self = [super initWithHost:host path:method.HTTP2Path requestsWriter:bytesWriter])) { + if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) { // A writeable that parses the proto messages received. _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { [responsesWriteable writeValue:[responseClass parseFromData:value error:NULL]]; diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 20a61b7b1cf..f9c2d5d8d6e 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -73,7 +73,7 @@ static ProtoMethod *kUnaryCallMethod; __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - path:kInexistentMethod.HTTP2Path + path:kInexistentMethod.HTTPPath requestsWriter:[GRXWriter writerWithValue:[NSData data]]]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -95,7 +95,7 @@ static ProtoMethod *kUnaryCallMethod; __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - path:kEmptyCallMethod.HTTP2Path + path:kEmptyCallMethod.HTTPPath requestsWriter:[GRXWriter writerWithValue:[NSData data]]]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -123,7 +123,7 @@ static ProtoMethod *kUnaryCallMethod; id requestsWriter = [GRXWriter writerWithValue:[request data]]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - path:kUnaryCallMethod.HTTP2Path + path:kUnaryCallMethod.HTTPPath requestsWriter:requestsWriter]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -153,7 +153,7 @@ static ProtoMethod *kUnaryCallMethod; id requestsWriter = [GRXWriter writerWithValue:[request data]]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress - path:kUnaryCallMethod.HTTP2Path + path:kUnaryCallMethod.HTTPPath requestsWriter:requestsWriter]; call.requestMetadata[@"Authorization"] = @"Bearer bogusToken"; diff --git a/src/objective-c/tests/LocalClearTextTests.m b/src/objective-c/tests/LocalClearTextTests.m index d9ad3455aff..10c9f13ea3b 100644 --- a/src/objective-c/tests/LocalClearTextTests.m +++ b/src/objective-c/tests/LocalClearTextTests.m @@ -94,7 +94,7 @@ static NSString * const kService = @"RouteGuide"; id requestsWriter = [GRXWriter emptyWriter]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost - path:method.HTTP2Path + path:method.HTTPPath requestsWriter:requestsWriter]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { @@ -125,7 +125,7 @@ static NSString * const kService = @"RouteGuide"; id requestsWriter = [GRXWriter writerWithValue:[point data]]; GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost - path:method.HTTP2Path + path:method.HTTPPath requestsWriter:requestsWriter]; id responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { From a82fef14b3caa94c133e9c49504243e28ea2cadd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Jul 2015 08:02:41 -0700 Subject: [PATCH 116/124] Fix bad assert, memory leak --- src/core/client_config/lb_policies/pick_first.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index 3d57e3136a4..73da624aff7 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -155,8 +155,6 @@ loop: switch (p->checking_connectivity) { case GRPC_CHANNEL_READY: p->selected = p->subchannels[p->checking_subchannel]; - GPR_ASSERT(grpc_subchannel_check_connectivity(p->selected) == - GRPC_CHANNEL_READY); while ((pp = p->pending_picks)) { p->pending_picks = pp->next; *pp->target = p->selected; @@ -185,6 +183,7 @@ loop: GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel], p->subchannels[p->num_subchannels - 1]); p->num_subchannels--; + GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); if (p->num_subchannels == 0) { while ((pp = p->pending_picks)) { p->pending_picks = pp->next; @@ -197,7 +196,6 @@ loop: p->checking_subchannel %= p->num_subchannels; p->checking_connectivity = grpc_subchannel_check_connectivity( p->subchannels[p->checking_subchannel]); - GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); add_interested_parties_locked(p); goto loop; } From 825b21cd1f999fa55e6234c2d0d8a6375f252c42 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Jul 2015 08:35:02 -0700 Subject: [PATCH 117/124] Fix segfault The server transport started reading fractionally too early, leading to the accept callback not being ready in some cases. --- src/core/security/server_secure_chttp2.c | 5 +++-- src/core/surface/channel_create.c | 3 ++- src/core/surface/secure_channel_create.c | 6 +++--- src/core/surface/server_chttp2.c | 3 ++- src/core/transport/chttp2_transport.c | 20 ++++++++++++-------- src/core/transport/chttp2_transport.h | 7 +++++-- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c index 6a99324da6b..8a7ada07af9 100644 --- a/src/core/security/server_secure_chttp2.c +++ b/src/core/security/server_secure_chttp2.c @@ -99,9 +99,10 @@ static void on_secure_transport_setup_done(void *statep, if (!state->is_shutdown) { mdctx = grpc_mdctx_create(); transport = grpc_create_chttp2_transport( - grpc_server_get_channel_args(state->server), secure_endpoint, NULL, 0, - mdctx, 0); + grpc_server_get_channel_args(state->server), secure_endpoint, mdctx, + 0); setup_transport(state, transport, mdctx); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } else { /* We need to consume this here, because the server may already have gone * away. */ diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 09b4fb782b9..e205f0a9f80 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -72,7 +72,8 @@ static void connected(void *arg, grpc_endpoint *tcp) { grpc_iomgr_closure *notify; if (tcp != NULL) { c->result->transport = grpc_create_chttp2_transport( - c->args.channel_args, tcp, NULL, 0, c->args.metadata_context, 1); + c->args.channel_args, tcp, c->args.metadata_context, 1); + grpc_chttp2_transport_start_reading(c->result->transport, NULL, 0); GPR_ASSERT(c->result->transport); c->result->filters = gpr_malloc(sizeof(grpc_channel_filter *)); c->result->filters[0] = &grpc_http_client_filter; diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c index 76fc862621f..34ee3f8400f 100644 --- a/src/core/surface/secure_channel_create.c +++ b/src/core/surface/secure_channel_create.c @@ -82,9 +82,9 @@ static void on_secure_transport_setup_done(void *arg, gpr_log(GPR_ERROR, "Secure transport setup failed with error %d.", status); memset(c->result, 0, sizeof(*c->result)); } else { - c->result->transport = - grpc_create_chttp2_transport(c->args.channel_args, secure_endpoint, - NULL, 0, c->args.metadata_context, 1); + c->result->transport = grpc_create_chttp2_transport( + c->args.channel_args, secure_endpoint, c->args.metadata_context, 1); + grpc_chttp2_transport_start_reading(c->result->transport, NULL, 0); c->result->filters = gpr_malloc(sizeof(grpc_channel_filter *) * 2); c->result->filters[0] = &grpc_client_auth_filter; c->result->filters[1] = &grpc_http_client_filter; diff --git a/src/core/surface/server_chttp2.c b/src/core/surface/server_chttp2.c index 9c02c3ef297..78c53466b38 100644 --- a/src/core/surface/server_chttp2.c +++ b/src/core/surface/server_chttp2.c @@ -61,8 +61,9 @@ static void new_transport(void *server, grpc_endpoint *tcp) { */ grpc_mdctx *mdctx = grpc_mdctx_create(); grpc_transport *transport = grpc_create_chttp2_transport( - grpc_server_get_channel_args(server), tcp, NULL, 0, mdctx, 0); + grpc_server_get_channel_args(server), tcp, mdctx, 0); setup_transport(server, transport, mdctx); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } /* Server callback: start listening on our ports */ diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 0aa28da8f79..054690ac959 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -201,8 +201,8 @@ static void ref_transport(grpc_chttp2_transport *t) { gpr_ref(&t->refs); } static void init_transport(grpc_chttp2_transport *t, const grpc_channel_args *channel_args, - grpc_endpoint *ep, gpr_slice *slices, size_t nslices, - grpc_mdctx *mdctx, int is_client) { + grpc_endpoint *ep, grpc_mdctx *mdctx, + int is_client) { size_t i; int j; @@ -311,9 +311,6 @@ static void init_transport(grpc_chttp2_transport *t, } } } - - REF_TRANSPORT(t, "recv_data"); /* matches unref inside recv_data */ - recv_data(t, slices, nslices, GRPC_ENDPOINT_CB_OK); } static void destroy_transport(grpc_transport *gt) { @@ -1043,9 +1040,16 @@ static const grpc_transport_vtable vtable = { perform_transport_op, destroy_stream, destroy_transport}; grpc_transport *grpc_create_chttp2_transport( - const grpc_channel_args *channel_args, grpc_endpoint *ep, gpr_slice *slices, - size_t nslices, grpc_mdctx *mdctx, int is_client) { + const grpc_channel_args *channel_args, grpc_endpoint *ep, grpc_mdctx *mdctx, + int is_client) { grpc_chttp2_transport *t = gpr_malloc(sizeof(grpc_chttp2_transport)); - init_transport(t, channel_args, ep, slices, nslices, mdctx, is_client); + init_transport(t, channel_args, ep, mdctx, is_client); return &t->base; } + +void grpc_chttp2_transport_start_reading(grpc_transport *transport, + gpr_slice *slices, size_t nslices) { + grpc_chttp2_transport *t = (grpc_chttp2_transport *)transport; + REF_TRANSPORT(t, "recv_data"); /* matches unref inside recv_data */ + recv_data(t, slices, nslices, GRPC_ENDPOINT_CB_OK); +} diff --git a/src/core/transport/chttp2_transport.h b/src/core/transport/chttp2_transport.h index 1747792b95e..fa0d6e4151e 100644 --- a/src/core/transport/chttp2_transport.h +++ b/src/core/transport/chttp2_transport.h @@ -41,7 +41,10 @@ extern int grpc_http_trace; extern int grpc_flowctl_trace; grpc_transport *grpc_create_chttp2_transport( - const grpc_channel_args *channel_args, grpc_endpoint *ep, gpr_slice *slices, - size_t nslices, grpc_mdctx *metadata_context, int is_client); + const grpc_channel_args *channel_args, grpc_endpoint *ep, + grpc_mdctx *metadata_context, int is_client); + +void grpc_chttp2_transport_start_reading(grpc_transport *transport, + gpr_slice *slices, size_t nslices); #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H */ From 3f2db5a4a19427d1c33dec5a1c917ab44b1d2d8b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Jul 2015 10:22:47 -0700 Subject: [PATCH 118/124] Fix potential double delete --- src/core/transport/chttp2/incoming_metadata.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/transport/chttp2/incoming_metadata.c b/src/core/transport/chttp2/incoming_metadata.c index a4b7174329b..68e0912b9ca 100644 --- a/src/core/transport/chttp2/incoming_metadata.c +++ b/src/core/transport/chttp2/incoming_metadata.c @@ -124,6 +124,7 @@ void grpc_incoming_metadata_buffer_move_to_referencing_sopb( sopb->ops[i].data.metadata.list.tail = (void *)(delta + (gpr_intptr)sopb->ops[i].data.metadata.list.tail); } + src->count = 0; } void grpc_chttp2_incoming_metadata_buffer_postprocess_sopb_and_begin_live_op( From f81ac3aced7fecde79458d9ec1b08414ddcdba06 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Jul 2015 09:50:55 -0700 Subject: [PATCH 119/124] Make log lines line up and be prettier --- src/core/support/log_linux.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/support/log_linux.c b/src/core/support/log_linux.c index 48349d2c831..7937466b79a 100644 --- a/src/core/support/log_linux.c +++ b/src/core/support/log_linux.c @@ -43,7 +43,9 @@ #ifdef GPR_LINUX +#include #include +#include #include #include #include @@ -71,6 +73,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, void gpr_default_log(gpr_log_func_args *args) { char *final_slash; + char *prefix; const char *display_file; char time_buffer[64]; gpr_timespec now = gpr_now(); @@ -89,10 +92,12 @@ void gpr_default_log(gpr_log_func_args *args) { strcpy(time_buffer, "error:strftime"); } - fprintf(stderr, "%s%s.%09d %7ld %s:%d] %s\n", + gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]", gpr_log_severity_string(args->severity), time_buffer, - (int)(now.tv_nsec), gettid(), display_file, args->line, - args->message); + (int)(now.tv_nsec), gettid(), display_file, args->line); + + fprintf(stderr, "%-60s %s\n", prefix, args->message); + gpr_free(prefix); } #endif From 043a0a83c52710ff3b23fe1a0425871456bb1ef2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Jul 2015 11:36:20 -0700 Subject: [PATCH 120/124] Add a short description of available resolution schemes --- src/core/client_config/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/client_config/README.md b/src/core/client_config/README.md index 7cb19cd130e..d7aed272233 100644 --- a/src/core/client_config/README.md +++ b/src/core/client_config/README.md @@ -42,3 +42,19 @@ Their behavior is specified by a set of grpc channel filters defined at their construction. To customize this behavior, resolvers build grpc_subchannel_factory objects, which use the decorator pattern to customize construction arguments for concrete grpc_subchannel instances. + + +Naming for GRPC +=============== + +Names in GRPC are represented by a URI. + +The following schemes are currently supported: + +dns:///host:port - dns schemes are currently supported so long as authority is + empty (authority based dns resolution is expected in a future + release) + +unix:path - the unix scheme is used to create and connect to unix domain + sockets - the authority must be empty, and the path represents + the absolute or relative path to the desired socket From 1dd7026cd28f5a64ea8fca766feb16a9cdfcded5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Jul 2015 11:45:30 -0700 Subject: [PATCH 121/124] Fixup some tests --- test/core/bad_client/bad_client.c | 3 ++- test/core/end2end/fixtures/chttp2_socket_pair.c | 8 ++++---- .../fixtures/chttp2_socket_pair_one_byte_at_a_time.c | 8 ++++---- .../end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c | 8 ++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 9b6a246075b..8ce666dcde5 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -108,8 +108,9 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, a.validator = validator; grpc_server_register_completion_queue(a.server, a.cq); grpc_server_start(a.server); - transport = grpc_create_chttp2_transport(NULL, sfd.server, NULL, 0, mdctx, 0); + transport = grpc_create_chttp2_transport(NULL, sfd.server, mdctx, 0); server_setup_transport(&a, transport, mdctx); + grpc_chttp2_transport_start_reading(transport, NULL, 0); /* Bind everything into the same pollset */ grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq)); diff --git a/test/core/end2end/fixtures/chttp2_socket_pair.c b/test/core/end2end/fixtures/chttp2_socket_pair.c index f42b9831c8d..be523608d0a 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair.c @@ -108,10 +108,10 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = - grpc_create_chttp2_transport(client_args, sfd->client, NULL, 0, mdctx, 1); + transport = grpc_create_chttp2_transport(client_args, sfd->client, mdctx, 1); client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, @@ -123,9 +123,9 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - transport = - grpc_create_chttp2_transport(server_args, sfd->server, NULL, 0, mdctx, 0); + transport = grpc_create_chttp2_transport(server_args, sfd->server, mdctx, 0); server_setup_transport(f, transport, mdctx); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c index be520380a70..f875ca54a50 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c @@ -108,10 +108,10 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = - grpc_create_chttp2_transport(client_args, sfd->client, NULL, 0, mdctx, 1); + transport = grpc_create_chttp2_transport(client_args, sfd->client, mdctx, 1); client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, @@ -123,9 +123,9 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - transport = - grpc_create_chttp2_transport(server_args, sfd->server, NULL, 0, mdctx, 0); + transport = grpc_create_chttp2_transport(server_args, sfd->server, mdctx, 0); server_setup_transport(f, transport, mdctx); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c index 037281c5ade..52c0e2ca8b2 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c @@ -109,10 +109,10 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = - grpc_create_chttp2_transport(client_args, sfd->client, NULL, 0, mdctx, 1); + transport = grpc_create_chttp2_transport(client_args, sfd->client, mdctx, 1); client_setup_transport(&cs, transport, mdctx); GPR_ASSERT(f->client); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, @@ -124,9 +124,9 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, f->server = grpc_server_create_from_filters(NULL, 0, server_args); grpc_server_register_completion_queue(f->server, f->cq); grpc_server_start(f->server); - transport = - grpc_create_chttp2_transport(server_args, sfd->server, NULL, 0, mdctx, 0); + transport = grpc_create_chttp2_transport(server_args, sfd->server, mdctx, 0); server_setup_transport(f, transport, mdctx); + grpc_chttp2_transport_start_reading(transport, NULL, 0); } static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { From 43f5ac6a28f02e9d154b36668717891252e87d64 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Jul 2015 14:09:23 -0700 Subject: [PATCH 122/124] Guard against double pollset shutdown completion --- src/core/iomgr/pollset_posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 15ed8e75e6c..12496440ded 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -249,7 +249,8 @@ static void basic_do_promote(void *args, int success) { pollset->in_flight_cbs--; if (pollset->shutting_down) { /* We don't care about this pollset anymore. */ - if (pollset->in_flight_cbs == 0 && pollset->counter == 0) { + if (pollset->in_flight_cbs == 0 && pollset->counter == 0 && !pollset->called_shutdown) { + pollset->called_shutdown = 1; do_shutdown_cb = 1; } } else if (grpc_fd_is_orphaned(fd)) { From bea1e621a120e1e9c1393479599cc9c4c710d648 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 7 Jul 2015 09:53:40 -0700 Subject: [PATCH 123/124] Fix Windows Crash --- src/core/transport/chttp2_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 054690ac959..3483512ab88 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -684,7 +684,7 @@ static void perform_transport_op(grpc_transport *gt, grpc_transport_op *op) { grpc_chttp2_goaway_append( t->global.last_incoming_stream_id, grpc_chttp2_grpc_status_to_http2_error(op->goaway_status), - *op->goaway_message, &t->global.qbuf); + gpr_slice_ref(*op->goaway_message), &t->global.qbuf); } if (op->set_accept_stream != NULL) { From 298b0b93ff764b4c94a165ba0bf6e70f2beb4d6d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 7 Jul 2015 12:44:22 -0700 Subject: [PATCH 124/124] Avoid finishing writes until data actually sent --- src/core/transport/chttp2/writing.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/transport/chttp2/writing.c b/src/core/transport/chttp2/writing.c index fdcc3000991..a78654334e1 100644 --- a/src/core/transport/chttp2/writing.c +++ b/src/core/transport/chttp2/writing.c @@ -97,12 +97,8 @@ int grpc_chttp2_unlocking_check_writes( grpc_chttp2_list_add_writing_stream(transport_writing, stream_writing); } - /* we should either exhaust window or have no ops left, but not both */ - if (stream_global->outgoing_sopb->nops == 0) { - stream_global->outgoing_sopb = NULL; - grpc_chttp2_schedule_closure(transport_global, - stream_global->send_done_closure, 1); - } else if (stream_global->outgoing_window > 0) { + if (stream_global->outgoing_window > 0 && + stream_global->outgoing_sopb->nops != 0) { grpc_chttp2_list_add_writable_stream(transport_global, stream_global); } } @@ -201,6 +197,11 @@ void grpc_chttp2_cleanup_writing( while (grpc_chttp2_list_pop_written_stream( transport_global, transport_writing, &stream_global, &stream_writing)) { + if (stream_global->outgoing_sopb->nops == 0) { + stream_global->outgoing_sopb = NULL; + grpc_chttp2_schedule_closure(transport_global, + stream_global->send_done_closure, 1); + } if (stream_writing->send_closed != GRPC_DONT_SEND_CLOSED) { stream_global->write_state = GRPC_WRITE_STATE_SENT_CLOSE; if (!transport_global->is_client) {